Guest User

Untitled

a guest
Jul 6th, 2018
192
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. 

  4. game.Players.PlayerAdded:connect(function(player)
  5. 

  6. local leader = player:WaitForChild("leaderstats")
  7. local Gold = Instance.new("IntValue",leader)
  8. Gold.Name = "Gold"
  9. Gold.Value = ds1:GetAsync(player.UserId) or 0
  10. ds1:SetAsync(player.UserId, Gold.Value)
  11.  
  12. Gold.Changed:connect(function()
  13. ds1:SetAsync(player.UserId, Gold.Value)
  14. end)
  15.  
  16. end)
  17. 

  18. game.Players.PlayerRemoving:connect(function(player)
  19. ds1:SetAsync(player.UserId, player.leaderstats.Gold.Value)
  20. end)
Advertisement
Add Comment
Please, Sign In to add comment