Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. local ServerStorage = game:GetService("ServerStorage")
  2. local DataStore = game:GetService("DataStoreService"):GetDataStore("Playersave3")
  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 SwordSkill = Instance.new("NumberValue")
  11. SwordSkill.Name = "SwordSkill"
  12. SwordSkill.Parent = leaderstats
  13.  
  14. local Cash = Instance.new("IntValue")
  15. Cash.Name = "Cash"
  16. Cash.Parent = leaderstats
  17.  
  18. local Rebirths = Instance.new("IntValue")
  19. Rebirths.Name = "Rebirths"
  20. Rebirths.Parent = leaderstats
  21.  
  22. local DataFolder = Instance.new("Folder")
  23. DataFolder.Name = player.name
  24. DataFolder.Parent = ServerStorage.RemoteData
  25.  
  26. local debounce = Instance.new("BoolValue")
  27. debounce.Name = "Debounce"
  28. debounce.Parent = DataFolder
  29.  
  30. local SwordSkillData, CashData, RebirthsData
  31.  
  32. local success,errormessage = pcall(function()
  33. SwordSkillData = DataStore:GetAsync("SwordSkill-"..player.UserId)
  34. CashData = DataStore:GetAsync("Cash-"..player.UserId)
  35. RebirthsData = DataStore:GetAsync("Rebirths-"..player.UserId)
  36. end)
  37.  
  38. if success then
  39. if SwordSkillData then
  40. SwordSkill.Value = SwordSkillData
  41. Cash.Value = CashData
  42. Rebirths.Value = RebirthsData
  43. end
  44. end
  45.  
  46. end)
  47.  
  48. game.Players.PlayerRemoving:Connect(function(player)
  49. local succes, errormessage = pcall(function()
  50. DataStore:SetAsync("SwordSkill-"..player.UserId,player.leaderstats.SwordSkill.Value)
  51. DataStore:SetAsync("Cash-"..player.UserId,player.leaderstats.Cash.Value)
  52. DataStore:SetAsync("Rebirths-"..player.UserId,player.leaderstats.Rebirths.Value)
  53. end)
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement