Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. local level = game:GetService("DataStoreService"):GetDataStore("Levels")
  2. local xp = game:GetService("DataStoreService"):GetDataStore("EXP")
  3. local axp = game:GetService("DataStoreService"):GetDataStore("AXP") -- amount xp needfunction savedata(dataname, playerid, value)
  4. game:GetService("DataStoreService"):GetDataStore(dataname):SetAsynce(playerid, value)
  5. endgame.Players.PlayerAdded:connect(function(player)
  6. local leader = Instance.new("Folder")
  7. leader.Name = "leaderstats"
  8. leader.Parent = player
  9. local levelz = Instance.new("IntValue")
  10. levelz.Value = level:GetAsync(tostring(player.userId)) or 1
  11. levelz.Name = "Level"
  12. levelz.Parent = player:WaitForChild("leaderstats")
  13. local xpz = Instance.new("NumberValue")
  14. xpz.Value = xp:GetAsync(tostring(player.userId))
  15. xpz.Name = "EXP"
  16. xpz.Parent = player
  17. local xpn = Instance.new("IntValue")
  18. xpn.Value = axp:GetAsync(tostring(player.userId)) or 700
  19. xpn.Name = "XpNeeded"
  20. xpn.Parent = player
  21.  
  22. xpz.Changed:connect(function()
  23. if player:WaitForChild("EXP").Value >= player:WaitForChild("XpNeeded") then
  24. levelz.Value = levelz.value+1
  25. xpn.Value = xpn.Value+700
  26. savedata("Levels",player.userid.levelz.Value)
  27. savedata("EXP",player.userid.xpz.Value)
  28. savedata("AXP",player.userid.xpn.Value)
  29. else
  30. savedata("Levels",player.userid.levelz.Value)
  31. savedata("EXP",player.userid.xpz.Value)
  32. savedata("AXP",player.userid.xpn.Value)
  33. end
  34. savedata("Levels",player.userid.levelz.Value)
  35. savedata("EXP",player.userid.xpz.Value)
  36. savedata("AXP",player.userid.xpn.Value)
  37. end)
  38. end)game.Players.PlayerRemoving:connect(function(player) savedata("Levels",player.userId.player.leaderstats.Level.Value)
  39. savedata("EXP",player.userId.player.EXP.Value)
  40. savedata("AXP",player.userId.player.XpNeeded.Value)
  41. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement