Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. local DataStore = game:GetService("DataStoreService")
  2. local ds1 = DataStore:GetDataStore("GoldSaveSystem")
  3. game.Players.PlayerAdded:connect(function(player)
  4. local leader = player:WaitForChild("leaderstats")
  5. local Gold = Instance.new("IntValue",leader)
  6. Gold.Name = "Gold"
  7. Gold.Value = ds1:GetAsync(player.UserId) or 0
  8. ds1:SetAsync(player.UserId, Gold.Value)
  9.  
  10. Gold.Changed:connect(function()
  11. ds1:SetAsync(player.UserId, Gold.Value)
  12. end)
  13.  
  14. end)
  15. game.Players.PlayerRemoving:connect(function(player)
  16. ds1:SetAsync(player.UserId, player.leaderstats.Gold.Value)
  17. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement