GlobalDataStore
Show Deprecated
A GlobalDataStore exposes functions for saving and loading data for the DataStoreService.
See Data Stores for an in-depth guide on data structure, management, error handling, etc.
Ordered data stores do not support versioning and metadata, so DataStoreKeyInfo is always nil for keys in an OrderedDataStore. If you need versioning and metadata support, use a DataStore.
Summary
Methods
Returns the value of a key in a specified data store and a DataStoreKeyInfo instance.
- IncrementAsync(key : string,delta : number,userIds : Array,options : DataStoreIncrementOptions):Variant
Increments the value of a key by the provided amount (both must be integers).
Removes the specified key while also retaining an accessible version.
Sets the value of the data store for the given key.
Updates a key's value with a new value from the specified callback function.
Properties
Methods
IncrementAsync
Variant
Parameters
Default Value: 1
Default Value: "{}"
Default Value: "nil"
Returns
Variant
OnUpdate
Parameters
Returns
Code Samples
Print Data Store Value on Update
local DataStoreService = game:GetService("DataStoreService")
local sampleDataStore = DataStoreService:GetDataStore("MyDataStore")
local connection
local function printOut(input)
print(input)
connection:Disconnect()
end
connection = sampleDataStore:OnUpdate("myKey", printOut)
local success, result = pcall(function()
sampleDataStore:SetAsync("myKey", 11)
end)
if not success then
warn(result)
end
SetAsync
Variant
Parameters
value: Variant
Default Value: "{}"
Default Value: "nil"
Returns
Variant