✓ Accepted answer
This is a pretty simple process, I have no idea where you have been looking but the script is everywhere and works from what I know. But here is the one I use, I have changed everything to money because thats what you used above.
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("MoneySaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Money = Instance.new("IntValue",leader)
Money.Name = "Money"
Money.Value = ds:GetAsync(player.UserId) or 0
Money.Changed:connect(function()
ds:SetAsync(player.UserId, Money.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Money.Value)
end)
I am aware that the details on that aren't 100% correct but I haven't got round to changing them from my script.
If you have any issues feel free to reply to this.
1 comment
Thanks, it works