local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
local success, errorMessageOrLoadValue, keyInfo = pcall(function()
return GoldStore:GetAsync(player.UserId)
end)
if not success then
print("errorMessage : ", errorMessageOrLoadValue)
else
local loadValue = errorMessageOrLoadValue
local createdTime = keyInfo.CreatedTime
local version = keyInfo.Version
local updatedTime = keyInfo.UpdatedTime
end
Version
string
Represents the version identifier of the key in the data store. Each version of a key has a unique identifier that allows developers to track or retrieve specific versions of the key.
Code Samples
local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
local success, errorMessageOrLoadValue, keyInfo = pcall(function()
return GoldStore:GetAsync(player.UserId)
end)
if not success then
print("errorMessage : ", errorMessageOrLoadValue)
else
local loadValue = errorMessageOrLoadValue
local createdTime = keyInfo.CreatedTime
local version = keyInfo.Version
local updatedTime = keyInfo.UpdatedTime
end
UpdatedTime
number
Indicates the last time the data store was updated in milliseconds since epoch.
Code Samples
local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
local success, errorMessageOrLoadValue, keyInfo = pcall(function()
return GoldStore:GetAsync(player.UserId)
end)
if not success then
print("errorMessage : ", errorMessageOrLoadValue)
else
local loadValue = errorMessageOrLoadValue
local createdTime = keyInfo.CreatedTime
local version = keyInfo.Version
local updatedTime = keyInfo.UpdatedTime
end
Methods
GetMetaData
The DataStoreKeyInfo:GetMetadata function retrieves the user-defined metadata associated with the latest version of a key in the data store, which was set using DataStoreSetOptions:SetMetadata.
Parameters
Return
Value
Code Samples
local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
local success, errorMessageOrLoadValue, keyInfo = pcall(function()
return GoldStore:GetAsync(player.UserId)
end)
if not success then
print("errorMessage : ", errorMessageOrLoadValue)
else
local loadValue = errorMessageOrLoadValue
local userIds = keyInfo:GetUserIds()
local metadata = keyInfo:GetMetadata()
end
GetUserIds
Retrieves a list of user IDs associated with the key in a data store. This enables developers to track user-specific interactions or ownership related to specific data entries.
Parameters
Return
Value
Code Samples
local DataStoreService = game:GetService("DataStoreService")
local GoldStore = DataStoreService:GetDataStore("PlayerGold")
local success, errorMessageOrLoadValue, keyInfo = pcall(function()
return GoldStore:GetAsync(player.UserId)
end)
if not success then
print("errorMessage : ", errorMessageOrLoadValue)
else
local loadValue = errorMessageOrLoadValue
local userIds = keyInfo:GetUserIds()
local metadata = keyInfo:GetMetadata()
end