Advertisement
xGabriel

Save Leaderstats (Leaderstats)

Nov 13th, 2019
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. local datastore = game:GetService("DataStoreService")
  2. local ds1 = datastore:GetDataStore("GemSaveSystem")
  3. local ds2 = datastore:GetDataStore("CashSaveSystem")
  4.  
  5. game.Players.PlayerAdded:connect(function(plr)
  6. local folder = Instance.new("Folder", plr)
  7. folder.Name = "leaderstats"
  8. local gems = Instance.new("IntValue", folder)
  9. gems.Name = "Coins"
  10. local cash = Instance.new("IntValue", folder)
  11. cash.Name = "Strengh"
  12.  
  13. gems.Value = ds1:GetAsync(plr.UserId) or 0
  14. ds1:SetAsync(plr.UserId, gems.Value)
  15.  
  16. cash.Value = ds2:GetAsync(plr.UserId) or 0
  17. ds2:SetAsync(plr.UserId, cash.Value)
  18.  
  19. gems.Changed:connect(function()
  20. ds1:SetAsync(plr.UserId, gems.Value)
  21. end)
  22.  
  23. cash.Changed:connect(function()
  24. ds2:SetAsync(plr.UserId, cash.Value)
  25. end)
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement