Before I can give specific input, I need to know a few things:
- How often is this code called/executed?
- What is the client (script/part of code in your project) of this code?
I did see some immediate issues:
- This is an incorrect use of
UpdateAsync. What you are doing here is conducting apcallagainstGetAsyncto retrieve the player’s data. If this fails, the update never occurs. However,UpdateAsyncdoes in fact have an internal “get.” InUpdateAsync, the current value is passed as an argument of your update function, and if your function returns something, the value is updated. Check the docs here. - You are conducting absolutely no backups. This also makes me think you have no disaster recovery plan. If you have 1000 concurrent users, your game is no longer a Roblox game; it is an enterprise service that users expect to function at a high degree of uptime and reliability. Not having backups / a disaster recovery plan is the easiest way to lose data if things go wrong. And data loss is one of the easiest ways to lose player trust.
- You have absolutely no instrumentation on this code. If something goes wrong, nothing is printed, making it impossible to investigate this issue by checking your game’s logs. You should, at minimum, print error messages if they occur so that you can check your game’s logs and get fine information about the error. What would be even better is tracking errors using an analytics service like Google Analytics or PlayFab so you have keep track of the amount of times errors are occurring across your entire game.
Building atop @Fusionet, many developers have noticed the shortcomings of DataStore and have built libraries that compensate for some of its issues. In addition to DataStore2, ProfileService is also a great alternative.