We use cookies on this site to enhance your user experience

DataStoreService

DataStoreService

The DataStoreService exposes methods for getting GlobalDataStore and OrderedDataStore objects through the methods DataStoreService/GetGlobalDataStore, DataStoreService/GetDataStore and DataStoreService/GetOrderedDataStore. Data stores can only be accessed by game servers, so you can only use DataStoreService within a Script or a ModuleScript that is used by a Script.

Like with all game services, you can use DataModel/GetService to access it:

local DataStoreService = game:GetService("DataStoreService")

Data Stores within Studio

DataStoreService cannot be used in studio if a game is not configured to allow studio access to API services. This option can be found under a game’s configuration on the Roblox website. Note that this is a game setting, not a place setting. In addition, if you are not editing a place through the Roblox website (e.g. a local rbxl file), you will need to call game:SetPlaceId(placeIdHere) in the Command bar before an in-studio game can access a game’s data store.

Request Limits

All data store requests are under request limits. This service also allows a game to query the budget of data store requests available on a per-method basis through the DataStoreService/GetRequestBudgetForRequestType method. See the code samples for a script that displays the present budget for all data store methods. Each place in a game is budgeted the following number of requests per minute:

Request type Methods Requests Allowed (per minute)
Gets `GetAsync` 60 + numPlayers * 10
Sets SetAsync, IncrementAsync, UpdateAsync, RemoveAsync 60 + numPlayers * 10
GetSorted (per page) GetSortedAsync 5 + numPlayers * 2
OnUpdate OnUpdate 30 + numPlayers * 5

In addition to the above request limits, there is also a 6 second write delay on the same key (this applies to calls on the same key with GlobalDataStore/SetAsync, GlobalDataStore/IncrementAsync, GlobalDataStore/UpdateAsync, and GlobalDataStore/RemoveAsync). Finally, individual keys on data stores can be throttled if many servers for the same game are trying to write to the same key. Should a key be throttled, you will see the message: "Request was throttled. Try sending fewer requests. Key = ".

Properties

Name Type Description
bool

Sets whether DataStore functions will automatically retry or not.

Inherited from Instance

Archivable ClassName DataCost Name Parent RobloxLocked

Functions

Name Type Description
Instance

Get a GlobalDataStore given a name and optional scope

Instance

Returns the default data store.

Instance

Get an OrderedDataStore given a name and optional scope

int

Returns the number of requests that can be made by the given request type.

Inherited from Instance

ClearAllChildren Clone Destroy FindFirstAncestor FindFirstAncestorOfClass FindFirstAncestorWhichIsA FindFirstChild FindFirstChildOfClass FindFirstChildWhichIsA GetChildren GetDebugId GetDescendants GetFullName GetPropertyChangedSignal IsA IsAncestorOf IsDescendantOf WaitForChild