Data Persistence

From Legacy Roblox Wiki
Jump to navigationJump to search

Ouch!
The following article, Data Persistence, mentions a feature exclusive to certain versions of the client.
Specifically: Data persistence was added in 2011 and requires the launcher or revival to support it.


Data Persistence is a method of saving data for games so that the data can then be loaded when the player visits the game again.

How it works

Before data can be loaded or saved, the script should make sure the data is loaded. This is done by waiting until the DataReady property of the player is true, which can be done using the WaitForDataReady method.

When the data is ready, scripts can use the methods SaveBoolean, SaveString, SaveNumber and SaveInstance to store data ready for saving. When the player leaves the game, the data is sent to the website.

When the player visits again, his data will be loaded, ready for the script to get the values back using the LoadBoolean, LoadString, LoadNumber and LoadInstance methods.

Example

To save data:

game.Players["Player"]:SaveString("Message", "Hello world!")

To load data:

print(game.Players["Player"]:LoadString("Message"))
Hello world!


Restrictions

The only major restriction with using the Data Persistence features is that none of the functions can be called from a LocalScript. Another small restriction is that there is a reasonable limit on how much data can be stored per player per place - see DataComplexity for details.

See Also

Tutorials

Methods

Blog Posts