When should I save data?

image
This is currently my game and I have fear of datastore requests being throttled so when should i save player data?

Should it be on interval or when the value changes?

I suggest changing data with PlayerRemoving and the BindToClose events!

2 Likes

at the end of the game would be best

You should consider using the module DataStore2 if your up to it. It is a module made to replace the default DataStore and its drawbacks. It works by updating data only when it is changed and includes a feature that saves data that is throttling. It sounds like this would be very useful to you as you are having issues with data throttling. Here is the original post with info on how to use it: DataStore2

You should save at intervals because servers can crash then you will lose the opportunity to save the data on exit be sure to save at intervals no less than 30 seconds.

As for data storing modules that prevent data loss I recommend ProfileService

ok this is funny now, second time in less then a week that I have been accused of being the original poster

I am laughing right now

1 Like

Hello, I’d recommend saving data when:

  • A player is being removed.
game.Players.PlayerRemoving:connect(function()

end)
  • When the server is about to shut down.
game:BindToClose(function()

end)

If you want, you could also add a script that saves data every 30 seconds(Like an Autosave)

You actually get a slightly larger budget when the server is shutting down, so you shouldn’t really have any worry regarding losing data when the server is closing. Though as others have mentioned it is possible that the server could crash before saving data so it’s best to save at intervals as well as when players leave the server.

As long as the server shuts down normally though, you should be fine unless there’s some flaw in your data handler design.

1 Like