PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

GetAsync

This function returns the latest value of the provided key and a DataStoreKeyInfo instance. If the key does not exist or if the latest version has been marked as deleted, both return values will be nil.

OrderedDataStore does not support versioning and metadata, so DataStoreKeyInfo will always be nil for keys in an OrderedDataStore.

To get a specific version, such as a version before the latest, use DataStore/GetVersionAsync.

See Also

  • Articles/Data store|Data Stores, an in-depth guide on data structure, management, error handling, etc.

Parameters

Name Type Default Description

key

The key name for which the value is requested. If DataStoreOptions/AllScopes was set to true when accessing the data store through DataStoreService/GetDataStore, this key name must be prepended with the original scope as in “scope/key”.

Returns

Return Type Summary

The value of the entry in the data store with the given key and a DataStoreKeyInfo instance that includes the version number, date and time the version was created, and functions to retrieve Player/UserId|UserIds and metadata.


Code Samples


Read Data Store Key/Value

local DataStoreService = game:GetService("DataStoreService")

local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
 
local success, currentExperience, keyInfo = pcall(function()
	return experienceStore:GetAsync("User_1234")
end)
if success then
	print(currentExperience)
	print(keyInfo.Version)
	print(keyInfo.CreatedTime)
	print(keyInfo.UpdatedTime)
	print(keyInfo:GetUserIds())
	print(keyInfo:GetMetadata())
end