Advertisement
SammyYT

ROBLOX SAVING LEADERSTATS

Jun 21st, 2020
9,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local DataStore = DataStoreService:GetDataStore("MoneyStats") -- Change this with a different name.
  3.  
  4. game.Players.PlayerAdded:Connect(function(Player)
  5. local Leaderstats = Instance.new("Folder", Player)
  6. Leaderstats.Name = "leaderstats"
  7.  
  8. local Cash= Instance.new("IntValue", Leaderstats)
  9. Cash.Name = "Cash"
  10. Cash.Value = 100
  11.  
  12. local Rebirths= Instance.new("IntValue", Leaderstats)
  13. Rebirths.Name = "Rebirths" -- Change "Rebirths" with your currency.
  14. Rebirths.Value = 0
  15.  
  16. local Data = DataStore:GetAsync(Player.UserId)
  17. if Data then
  18. Cash.Value = Data.Cash -- Change "Money" with your currency.
  19. Rebirths.Value = Data.Rebirths -- Change "Rebirths" with your currency.
  20. end
  21. end)
  22.  
  23. game.Players.PlayerRemoving:Connect(function(Player)
  24. DataStore:SetAsync(Player.UserId, {
  25. ["Cash"] = Player.leaderstats.Cash.Value; -- Change "Money" with your currency.
  26. ["Rebirths"] = Player.leaderstats.Rebirths.Value; -- Change "Rebirths" with your currency.
  27. })
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement