Basically what the title says
In a multiplayer setting, what would be the best practice for handling storing, editing, and reading save data? Should it all go through a module script? Should everything go through a singular saving script or should it be modularized? Is using _G a bad idea? How should data be stored locally (since constantly calling the datastore won’t go well)? How should conflicts be handled (if they occur)? When should UpdateAsync be used over SetAsync? How should backups (in case of corruption) be handled? When should you use multiple DataStores? (yes that’s a lot of questions)
I just want to know everything I need to know. Kindly do not recommend third-party modules (such as ProfileService). My goal is to learn best practices and learn how to handle it myself not just to quickly make a saving system. Tutorials are fine however.
Just datastore all info on start and end
Works very well, and there are not that many usecases where another technique would be required
The less requests made to datastore API, the better
Would it be bad practice to also store data periodically (like every 5 minutes) just to be safe? I really don’t like the idea of risking data loss in case something goes wrong
They removed the time limit on datastores though, so even if there was a server shutdown, you could link a bind-to-close to stall for time to get the rest of all your players’ data saved
Im using module script for saving because i think its much easier to interact with. I have a function Get which returns stats and can be easily changed.
If save failed on player leaving, there is not much things you can do, if that happened, probably your periodic save works incorrectly. If periodic save falied im kicking the player from the game to prevent dataloss.
I recommend using UpdateAsync for saving player stats because it works faster for cross-server replicating stats.
Use different datastores for leaderboards, player stats, moderation logs and etc
Well checking the limits I guess it depends how you store data
If you store everything within a json encoded table then you are really unlikely to hit the limit, however if you store everything under different scopes or datastores all together, you probably will hit it really quick