Advertisement
aarontje11002

rpg script

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