Should I not award purchased coins if coin save fails?

Basically, I have a currency that I save every time the player leaves the game (the saving system is quite secure I think), the player can also buy currency. When a player buys currency it automatically saves (without waiting for them to leave)… if the save succeeds, the player is awarded their coins (they are added to their leaderstat). But if it does not succeed, I currently send a message trough webhooks and I would probably award it to the player manually. This is because if it did fail and I still gave them the coins, the leaderstat value would be different from the save. Now you may say it will save once they leave, but what if that fails too?
I want to make sure that if the player’s get their coins, the save is successful, else it would create even more confusion and trouble. Is this a good way to do it? And should I even be this worried about data saves failing?

I also have another concern… I want to make sure that it doesn’t attempt the purchase and saving coins unless the player’s data is already loaded to prevent data loss. I have this quite sorted out, however as you may know, if the player leaves jsut after buying a devproduct, it is common to return:
´Enum.ProductPurchaseDecision.NotProcessedYet´
in the processReceipt() function in order to retry the process once the player rejoins. If the player rejoins, I am not sure how to make it wait for the data to get loaded before retrying the process. Should I just return ´NotProcessedYet´ again if the data isn’t loaded? What will happen if I do that?

You could award the coins through a call to the “pcall()” function, if its successful then do nothing, if it fails then retry.

I am already saving the data in a pcall, retrying 3 times incase it fails. I can’t retry forever since if it fails 3 times, something is probably wrong and it would just fill the DataStore limits.
I am awarding the coins if the pcall succeeds.

You could use repeat wait until() player's data loads for the latter part of your post. GetAsync() will allow you to check if the data has loaded yet.

1 Like

Have you investigated Datastore2? It’s apparently a save game module with a much better track record than the default service. I have it bookmarked, but haven’t taken the plunge yet.

How to use DataStore2 - Data Store caching and data loss prevention - Resources / Community Tutorials - DevForum | Roblox

I had considered that before, but I was far into the development and I didn’t feel like rewriting it. I think my datastores are quite secure anyway. And I don’t think Datastore2 would fix my issue specifically.