Advertisement
lafur

Untitled

Jan 18th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. --coolmanausten is the creator of this script
  2. function onXPChanged(player, XP, level)
  3. if XP.Value>=level.Value * 10 then
  4. XP.Value = XP.Value - level.Value * 30
  5. level.Value = level.Value + 1
  6. end
  7. end
  8.  
  9. function onLevelUp(player, XP, level)
  10. if player.Character~=nil then
  11. for i = 1,5 do
  12. local fireworks = Instance.new("Part")
  13. fireworks.Shape = 0
  14. fireworks.formFactor = "Symmetric"
  15. fireworks.Size = Vector3.new(1,1,1)
  16. fireworks.BrickColor = BrickColor.Random()
  17. fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0)
  18. fireworks.Parent = game.Workspace
  19. game:GetService("Debris"):AddItem(fireworks, 2)
  20. fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
  21. end
  22. end
  23. local m = Instance.new("Hint")
  24. m.Parent = game.Workspace
  25. m.Text = player.Name .. " has leveled up!"
  26. wait(3)
  27. m.Parent = nil
  28. end
  29.  
  30. function onPlayerRespawned(player)
  31. wait(5)
  32. player.Character.Humanoid.Health = player.leaderstats.Level * 50
  33. player.Character.Humanoid.MaxHealth = player.leaderstats.Level * 50
  34. --[[
  35. local stuff = player.Backpack:GetChildren()
  36. wait(5)
  37. for i = 1,#stuff do
  38. local name = stuff[i].Name
  39. if game.Starterpack:findFirstChild(name)==nil then
  40. stuff[i]:Clone().Parent = player.Backpack
  41. end
  42. end
  43. --]]
  44. end
  45.  
  46. function onPlayerEntered(newPlayer)
  47. local stats = Instance.new("IntValue")
  48. stats.Name = "leaderstats"
  49.  
  50. local xp = Instance.new("IntValue")
  51. xp.Name = "XP"
  52. xp.Value = 0
  53.  
  54. local level = Instance.new("IntValue")
  55. level.Name = "Lvl"
  56. level.Value = 1
  57.  
  58. local c = Instance.new("IntValue")
  59. c.Name = "Gold"
  60. c.Value = 50
  61.  
  62. xp.Parent = stats
  63. level.Parent = stats
  64. c.Parent = stats
  65.  
  66. stats.Parent = newPlayer
  67.  
  68. xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end)
  69. level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end)
  70.  
  71. newPlayer.Changed:connect(function (property)
  72. if (property == "Character") then
  73. onPlayerRespawned(newPlayer)
  74. end
  75. end)
  76. end
  77.  
  78. game.Players.ChildAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement