Data Persistence
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.
To save data:
game.Players["Player"]:SaveString("Message", "Hello world!")
To load data:
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
- ROBLOX Scripting How To: Data Persistence
- Data Persistence Tutorial
- How To Efficiently Use Data Persistence
- Data Persistence Complete Guide