Problem with saving leaderstats

I’m currently trying to make a datastore that saves their money value, or in my game, ringgit. What I’ve done is used game.Players.PlayerRemoving function and then save it when it runs.
My script:

    local money = player.leaderstats.Ringgit.Value
    local datastore = game:GetService("DataStoreService"):GetDataStore("MAMoneyData")
    datastore:SetAsync(player.UserId, money)

After that I used console to give myself money:

And when I left, this is what was printed:

Please let me know what I did wrong!

Are you modifying the money on the client?

I modified it using Roblox’s command bar on the bottom.

You executed the change on the client; changes made on the client do not replicate to the server.

If you’re running in the client, the command bar runs a local script, try switching to the server before run the command.

I tried it and turns out it work, thank you.

1 Like