DataStores refuse to save leaderstats

I have been doing a lot of testing with my game, sometimes using an alternate account for testing DataStores.
I have noticed that when my alternate account leaves a game with some currency, the game refuses the account’s progress to save, resetting their stats to 0.
Proof (ignore the obnoxious alternate account name)

This resets the first player with 25 bits (SpriteCranbrry) to 0, when SpriteCranbrry leaves.

Is my code wrong or does DataStore currently have issues at the time of writing?

CODE: Stats Code - Pastebin.com

1 Like

Is the “saved” at line 55 actually printed?

Also, can you surround both pcalls with prints? pcall returns false if there is an error + the error message.

1 Like

“saved” is not printed.

It appears on line 54, you forgot to capitalize “bits”, so it is unable to find the “Bits” IntValue as it is searching for an object called “bits” which doesn’t exist. Try changing line 54 to the line of code below and see if it fixes the issue as expected:

dataStores:SetAsync(player.UserId.."-Bits",player.leaderstats.Bits.Value)

4 Likes

Happens to the best of us. Sometimes these little things can change so much. :joy:

2 Likes

Typos happen sometimes.

1 Like

And it works! Thank you! Typos are so annoying when scripting!

3 Likes