hmmm… So problem is data store saves too slow?
Maybe if you save tables in server script, when player leaves, there is no need to haste, just get data from that server script and save it.
I use this in my games, its bit slow from time to time but it works.
EDIT: this code up works for me.
Tried it, keeps refreshing to 0 cash everytime I rejoin…
Is there any error? And is your cash value 0 before u leave?
Edit: You need to wait for sometime as it takes time to fetch data from datastore after joining.
No errors, I set my cash 1,000 (from the developer console, server-side) and then purchased something from the in-game shop that costs 100, my cash is 900. I leave and come back. My cash is 0 again.
Updated, I forgot to add .Cash after leaderstats
Hmmm… have you tried to save value before you leave?
Is it 0?
If its not then something is broken when leaving, else your save system is broken.
It saves the 1,000 now. But doesn’t save the amount that get’s changed. Which in this case is 900.
What do you mean save the value before I leave?
Then you’re probably not updating it in leaderstats of the player.
game.Players.YXM00N.leaderstats.Cash.Value += 1000 -- if you want to add 1000
Oh… I am so dumb and just realized that I have the script that deducts the cash of the player in a local script instead of a server script, let me fix that real quick and get back to you.
It works now! I am so dumb, thank you for the help