Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStore = game:GetService("DataStoreService")
- local ds1 = DataStore:GetDataStore("GoldSaveSystem")
- game.Players.PlayerAdded:connect(function(player)
- local leader = player:WaitForChild("leaderstats")
- local Gold = Instance.new("IntValue",leader)
- Gold.Name = "Gold"
- Gold.Value = ds1:GetAsync(player.UserId) or 0
- ds1:SetAsync(player.UserId, Gold.Value)
- Gold.Changed:connect(function()
- ds1:SetAsync(player.UserId, Gold.Value)
- end)
- end)
- game.Players.PlayerRemoving:connect(function(player)
- ds1:SetAsync(player.UserId, player.leaderstats.Gold.Value)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement