Data Functions
A brief summary of all available DataStore related functions.
Recommended if you would like to keep data saved for the next time a player comes to play your game again.
If you plan on testing your scripts that use the module in Studio, playtest your game in the Roblox client first. Otherwise, the Player Data functions may not work as intended.
getData(player: Player): {any}
getData(player: Player): {any}
Returns the provided Player
's leaderboard data.
This function contains the GetAsync()
method which can have a chance to fail. Wrapping the function in a protected thread (a.k.a pcall()
) is strongly recommended.
Example
saveData(player: Player)
saveData(player: Player)
Saves all of the current values inside of the Player
's leaderstats folder into the datastore.
Just like getData()
, saveData()
has the SetAsync()
Datastore function, which can also have a chance to fail. Wrapping the function in a pcall()
is strongly recommended.
Example
eraseData(player: Player): {any}
eraseData(player: Player): {any}
Clears a Player's Datastore key if there's any data present within it.
Just like the 2 functions above, eraseData()
uses RemoveAsync()
, which is also another Datastore method. Wrapping the function in a pcall()
is strongly recommended.
If there is no systems in your game that allows players to recover data, this function's actions CANNOT be reversed. Only use this function under exceptional circumstances if there's no data recovery systems in place.
Example
Last updated