Causes of player data loss

So I’ve heard of multiple occasions where data loss has occurred. Since I’m nearing the release of my own game, I want to make sure it doesn’t happen to me. So, what are all the possible causes of player data loss? Just normal, player data, saved in a DataStore.

I’m not entirely sure why the data loss occurs, but I believe it’s due to Roblox’s servers.
If you want to guarantee no data loss, use Datastore2 based on bereeza’s method of using datastores.

1 Like

Some pointers about saving data

  • If data fails to load, DO NOT SAVE IT. Add a value or indication somewhere that the player’s data loaded successfully when it does. When saving, make sure that value exists
  • Use UpdateAsync instead of SetAsync. This way, you can be sure you want to overide data. For example, don’t override a level 200 account with a level 1 one
  • Create backups. DataStore2 has this feature and it can be very useful. The ability to roll back data if need be is amazing.
  • When a request fails, notify the player. Let them know that if they leave, their data may not save.
  • Autosave every x seconds. Don’t just save when the player leaves, as servers can crash and you risk losing hours of playtime if you don’t.

More Info

We need more info such as your code to truly figure out what the problem is, but as long as you do the above you should be fine.

18 Likes

Maybe you should cross that bridge when you get to it. Data loss is a very broad topic and doing something wrong in a data handling script can easily yield data loss. Specific cases and tests should be done by yourself in order to test the waters.

1 Like

Nice, I’ll definitely try it out! :+1:

1 Like

I’ll keep those in mind, thanks!

As the others have said, data loss is a very broad topic and has lots of solutions based on your game. Their is a few things you can do to reduce the chance of data loss:

  • Try and not use DataStores extensively for other things than loading and saving data.

  • Make sure you auto save in regular intervals like every 1 or 2 minutes. If you autosave a player will only lose a couple of minutes of progress if there is a datastore error. Remember don’t auto save too often otherwise the DataStore will yeild. The minimum time between each autosave should be 1 minute.

  • Make sure you stick to the datastore limits: https://developer.roblox.com/articles/Datastore-Errors

  • When updating the players DataStore don’t use SetAsync but instead use UpdateAsync.

You may want to read other this community tutorial as it explains about data loss: Stop using SetAsync() to save player data

3 Likes

DataStore2 can still experience data loss based on programming practices, it’s not a data loss free card.

That’s true of… anything? ‘If you do it wrong it might not work’ is hardly a controversial statement. Also try not to necro

Probably one of the best ways to handle data saving in your system is to create a table based on how you should save your data

For me, it’s four different tiers
Always - This data should always be saved when changed: things like store purchases, microtransactions etc.
Periodic - This data can be held in a temporary storage dictionary and then updated at certain intervals: i.e. end of round etc.
PlayerLeaving - This data should only be saved when a player is leaving
ServerClosing - This data should only be saved when the server is closing down

And remember, DO NOT SAVE ANYTHING, IF THE OLD VALUE COULD NOT BE GAINED DUE TO ERRORS


I’ve also seen alot of people recommending backups, seriously, no. It’s not worth gunking up your datastores just to hold backups so that 1 user out of 10,000,000 users can get old data.

1 Like