Advertisement
goku13l

sumilator

Feb 11th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. local datastore = game:GetService("DataStoreService"):GetDataStore("Divine'sHats")
  2.  
  3. game.Players.PlayerAdded:Connect(function(player)
  4. local leaderstats = Instance.new("Folder")
  5. leaderstats.Parent = player
  6. leaderstats.Name = "leaderstats"
  7.  
  8. local cash = Instance.new("NumberValue")
  9. cash.Parent = leaderstats
  10. cash.Name = "Cash"
  11.  
  12. local power = Instance.new("NumberValue")
  13. power.Parent = leaderstats
  14. power.Name = "Power"
  15.  
  16. local rebirths = Instance.new("NumberValue")
  17. rebirths.Parent = leaderstats
  18. rebirths.Name = "Rebirths"
  19.  
  20. local debounce = Instance.new("BoolValue")
  21. debounce.Value = false
  22. debounce.Name = "Debounce"
  23. debounce.Parent = player
  24.  
  25. local key = "user-" .. player.userId
  26.  
  27. local storeditems = datastore:GetAsync(key)
  28.  
  29. if storeditems then
  30. cash.Value = storeditems[1] --Value of the cash, change "points" if you changed line 10
  31. rebirths.Value = storeditems[2]
  32. power.Value = storeditems[3]
  33. else
  34. local items = {cash.Value, rebirths.Value, power.Value}
  35. datastore:SetAsync(key, items)
  36. end
  37. end)
  38.  
  39. game.Players.PlayerRemoving:connect(function(player)
  40. local items = {player.leaderstats.Cash.Value, player.leaderstats.Rebirths.Value, player.leaderstats.Power.Value}
  41. local key = "user-" .. player.userId
  42.  
  43. datastore:SetAsync(key, items)
  44. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement