I found a data save from the Roblox wiki and it works well except if you go in game with some ingame money and spend it to 0, then if you leave and rejoin the game, you will have your original amount of money. It doesn't seem to save 0s.
scoreKey = "PlayerScore"
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
-- create leaderboard
local ls = Instance.new("IntValue")
ls.Name = "leaderstats"
ls.Parent = player
--create the score stat
local score = Instance.new("IntValue")
score.Name = "Money"
score.Parent = ls
score.Value = player:LoadNumber(scoreKey)
end
end)
game.Players.PlayerRemoving:connect(function(player)
if player:FindFirstChild("leaderstats") then
player:SaveNumber(scoreKey, player.leaderstats.Money.Value)
end
end)
Please help, I assume is is only a matter of a few lines of code.

1 comment
M39a9am3R - When I put it in Roblox, it says it is broken and the last end is underlined.