DataStore Not Saving Data

My datastore won’t save…

Script:

Output:

Screenshot (64)

It did warn me with the message, just didn’t save the player’s gold.

It’s likely not saving because your studio game instance is closing faster than the script can run, use BindToClose() and save data for each player.

Are you test in roblox studio? Try to test in Roblox.

EDIT: Try to print error message

if not success then
    print(err)
end

Hm, please do print(err) so we can know the error

Oh yeah I know why, you’re doing (on save)

You’re doing:

plr.leaderstats.gold.Value

You should be doing

plr.leaderstats.Gold.Value

3 Likes

While it is better to use BindToClose() here, that’s not the problem; actually studio does have some consideration for Player removing events so ,¯\_(ツ)_/¯

Yea, he should change that

gold.Name = "gold"

Hm no, he should not change the name of the gold, else everyone would see gold as a lowercase thing, it looks ugly, so just changing the save name is what he should do :P

1 Like

I printed (err) and the output says:


gold is not a valid member of Folder "Players.Mysterious_Myth11.leaderstats

Thanks a lot, that was a very silly mistake. I’ll be sure to be aware next time! :smiley: