Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. local dataStoreService = game:GetService("DataStoreService")
  2. local playerData = dataStoreService:GetDataStore("playerData")
  3.  
  4. sessionData = {}
  5.  
  6. game.Players.PlayerAdded:Connect(function(player)
  7. local leaderStats = Instance.new("Folder")
  8. leaderStats.Name = "leaderStats"
  9. leaderStats.Parent = player
  10.  
  11. local level = Instance.new("IntValue")
  12. level.Name = "level"
  13. level.Parent = leaderStats
  14. level.Value = 1
  15.  
  16. local experience = Instance.new("IntValue")
  17. experience.Name = "experience"
  18. experience.Parent = leaderStats
  19. experience.Value = 0
  20.  
  21. local experienceNeeded = Instance.new("IntValue")
  22. experienceNeeded.Name = "experienceNeeded"
  23. experienceNeeded.Parent = leaderStats
  24. experienceNeeded.Value = 5
  25.  
  26. local currentSpeed = Instance.new("IntValue")
  27. currentSpeed.Name = "currentSpeed"
  28. currentSpeed.Parent = leaderStats
  29. currentSpeed.Value = 16
  30.  
  31. local maxSpeed = Instance.new("IntValue")
  32. maxSpeed.Name = "maxSpeed"
  33. maxSpeed.Parent = leaderStats
  34. maxSpeed.Value = 54
  35.  
  36. local currentAcceleration = Instance.new("IntValue")
  37. currentAcceleration.Name = "currentAcceleration"
  38. currentAcceleration.Parent = leaderStats
  39. currentAcceleration.Value = 0
  40.  
  41. local maxAcceleration = Instance.new("IntValue")
  42. maxAcceleration.Name = "maxAcceleration"
  43. maxAcceleration.Parent = leaderStats
  44. maxAcceleration.Value = 11
  45.  
  46. local playerUserId = "player_"..player.userId
  47. local data = playerData:GetAsync(playerUserId)
  48.  
  49. if data then
  50. print("Successfully loaded "..player.Name.."'s data!")
  51. sessionData[playerUserId] = data
  52.  
  53. level.Value = data.level
  54. experience.Value = data.experience
  55. experienceNeeded.Value = data.experienceNeeded
  56. maxSpeed.Value = data.maxSpeed
  57. maxAcceleration.Value = data.maxSpeed
  58. else
  59. print(player.name.." has no current data, creating new data!")
  60. sessionData[playerUserId] = {
  61. level = 1,
  62. experience = 0,
  63. experienceNeeded = 5,
  64. maxSpeed = 54,
  65. maxAcceleration = 11
  66. }
  67. end
  68. end)
  69.  
  70. return sessionData
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement