Advertisement
TheGuyThatHasTheStuf

rebirths and strength leaderstats

Mar 1st, 2020
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. local serverStorage = game:GetService("ServerStorage")
  2. local DataStore = game:GetService("DataStoreService"):GetDataStore("PlayerSave")
  3.  
  4. game.Players.PlayerAdded:Connect(function(player)
  5.  
  6. local leaderstats = Instance.new("Folder")
  7. leaderstats.Name = "leaderstats"
  8. leaderstats.Parent = player
  9.  
  10. local Coins = Instance.new("NumberValue")
  11. Coins.Name = "Coins"
  12. Coins.Parent = leaderstats
  13.  
  14. local rebirths = Instance.new("IntValue")
  15. rebirths.Name = "Rebirths"
  16. rebirths.Parent = leaderstats
  17.  
  18. local dataFolder = Instance.new("Folder")
  19. dataFolder.Name = player.Name
  20. dataFolder.Parent = serverStorage.RemoteData
  21.  
  22. local debounce = Instance.new("BoolValue")
  23. debounce.Name = "Debounce"
  24. debounce.Parent = dataFolder
  25.  
  26. local strengthData, rebirthsData
  27.  
  28. local success,errormessage = pcall(function()
  29. strengthData = DataStore:GetAsync("coins-"..player.UserId)
  30. rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
  31. end)
  32.  
  33. if success then
  34. if strengthData then
  35. coins.Value = coinsData
  36. rebirths.Value = rebirthsData
  37. end
  38. end
  39.  
  40. game.Players.PlayerRemoving:Connect(function(player)
  41. local success, errormessage = pcall(function()
  42. DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Coins.Value)
  43. DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Rebirths.Value)
  44. end)
  45. end)
  46. end)
  47. print("GOT PAST THE WHOLE SCRIPT!") -- make a script in ServerScriptService and paste all of this in
  48. -- you can delete the print and instructions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement