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.
game.Players.PlayerRemoving:Connect(function(player) print(player.leaderstats.Ringgit.Value) local money = player.leaderstats.Ringgit.Value print(money) local datastore = game:GetService("DataStoreService"):GetDataStore("MAMoneyData") datastore:SetAsync(player.UserId, money) end)
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!