Datastores don't work properly on rare occasions


I made a poorly done post a few days back on this subject, but recently some changes were modified to the datastore by @SteadyOn and I, but there are still reports of players losing data.

Here’s the a pastebin of our saving/loading data. It loads when the player joins, and saves when they leave.

I’ve looked over my system multiple times, but I still can’t get my head around why it isn’t working.

I’ve decided to spend a good hour on my game, playing, rejoining, etc. But my data saves and loads just fine every time, yet me and @TheHyb still are getting complaints about data loss.

I even looked in the server log for errors, but there are always NONE.

Any idea on what could be wrong?


The player leaving is not always the most reliable method. Servers crash, other edge cases happen. You should consider saving data at a regular interval. A common one is to do it every minute, as it should help to keep you from hitting your limits.


I’m talking about people who already have had data in the past and have played multiple times are losing their data.

Talking about people who already had some data, not new people’s data not saving.


I don’t think the code you’ve provided is enough to fully diagnose the issue. There are a few obvious problems, but I need to see a few things:

  • PlayerRemoving code
  • GetData function

The largest issue I see right now is the fact that you are only waiting 1 second between failed attempts when saving data. A data store limitation is the fact that write requests to the same key have a 6 second cooldown.


If this helps here you go

GetData() is just a function to get the player’s folder of data that will be used in the datastore


Really stumped on this


You should also be auto-saving every so often (e.g. every 60 seconds–nothing super frequent), and also make sure you save when the game closes using BindToClose. This is crucial, because it allows your game to prevent itself from actually closing down until all the tasks are done within the BindToClose functions. If you only rely on PlayerLeaving, it might not be able to save data for the last player to leave.


Just added that, I don’t think it’ll solve all my problems, but we’ll see.


Store player data in ReplicatedStorage or ServerStorage. Never store it in the actual player object. Always use BindToClose to save for the last player like Crazyman32 said. Save in a few minute intervals in case of a crash. A combination of all of these methods haven’t failed me yet when I apply them.


Players are still reporting data loss. I honestly give up at this point.


I’ve decided to switch to storing data in ReplicatedStorage, hopefully this will work.