This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
This function returns the value of the entry in the
GlobalDataStore with the given key. If the key does not exist, returns
nil. This function caches for about 4 seconds, so you cannot be sure that it returns the current value saved on the Roblox servers.
If this function throws an error, the
Articles/Datastore Errors|error message will describe the problem. Note that there are also
Articles/Datastore Errors|limits that apply to this function.
To save a data store entry, you can use one of several possible functions, including
The key identifying the entry being retrieved from the data store
The value of the entry in the data store with the given key
Data Store to Leaderboard
This code sample retrieves a player’s saved gold from a data store and puts the returned value onto the leaderboard. Note that this sample does not save players’ gold — it only loads it.