DataStoreService
DataStoreService : Instance
Overview
DataStoreService provides access to data storage in server environment.
Properties
Methods
GetDataStore
Creates a new DataStore object based on the provided name and returns it. If it is called again with the same name, it reuses previously created instance.
Parameters
string InName
The name of a DataStore object.
string InScope
A scope string used to distinguish keys within the DataStore. It can be left empty, and when provided, must be 50 characters or less.
Instance InOption
An option instance used to specify additional behavior when creating the DataStore. If not specified, it is created with default settings.
Return
GlobalDataStore
The returned DataStore object.
Code Samples
GetGlobalDataStore
Returns default global data store provided by system. The GetDataStore function must be used to access a separate data storage with a specific name.
Parameters
Return
GlobalDataStore
The returned GlobalDataStore object.
Code Samples
GetOrderedDataStore
Returns the OrderedDataStore object that corresponds to the provided name and scope. OrderedDataStore can only hold integer values and allows retrieval sorted by the stored values, which makes it suitable for building leaderboards.
Calling it again with the same name and scope returns the same object that was returned previously. Calling it with the scope omitted and calling it with global as the scope return the same object.
This method can only be called from a server Script. Calling it from a client LocalScript raises an error.
Important Notes
It uses storage separate from a DataStore retrieved with GetDataStore even when the name is identical, and the values never mix.
Names, scopes, and keys are all case sensitive. Names that differ only in case are separate storage.
In studio test environments, a temporary store is used without any additional setup, and the saved data is deleted when the test session ends.
Parameters
string InName
The name of an OrderedDataStore object. Must be 50 characters or less.
string InScope
(Optional) A scope string used to separate storage within the OrderedDataStore.
If omitted, global is used.
An empty string or a string longer than 50 characters raises an error.
Return
OrderedDataStore
The returned OrderedDataStore object.
Code Samples
Events
See also
Saving & Loading DataCustom LeaderboardLast updated