Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onXPChanged(player, XP, level)
- if XP.Value>=level.Value * 100 then
- XP.Value = XP.Value - level.Value * 100
- level.Value = level.Value + 2
- end
- end
- function onLevelUp(player, XP, level)
- if player.Character~=nil then
- for i = 1,5 do
- local fireworks = Instance.new("Part")
- fireworks.Shape = 0
- fireworks.formFactor = "Symmetric"
- fireworks.Size = Vector3.new(1,1,1)
- fireworks.BrickColor = BrickColor.Random()
- fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0)
- fireworks.Parent = game.Workspace
- game:GetService("Debris"):AddItem(fireworks, 2)
- fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
- end
- end
- local m = Instance.new("Hint")
- m.Parent = game.Workspace
- m.Text = player.Name .. " LVL up"
- wait(3)
- m.Parent = nil
- end
- function onPlayerRespawned(player)
- wait(5)
- player.Character.Humanoid.Health = player.leaderstats.Level * 100
- player.Character.Humanoid.MaxHealth = player.leaderstats.Level * 100
- --[[
- local stuff = player.Backpack:GetChildren()
- wait(5)
- for i = 1,#stuff do
- local name = stuff[i].Name
- if game.Starterpack:findFirstChild(name)==nil then
- stuff[i]:Clone().Parent = player.Backpack
- end
- end
- --]]
- end
- function onPlayerEntered(newPlayer)
- local stats = Instance.new("IntValue")
- stats.Name = "leaderstats"
- local xp = Instance.new("IntValue")
- xp.Name = "XP"
- xp.Value = 0
- local level = Instance.new("IntValue")
- level.Name = "Lvl"
- level.Value = 1
- local c = Instance.new
- xp.Parent = stats
- level.Parent = stats
- c.Parent = stats
- stats.Parent = newPlayer
- xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end)
- level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end)
- newPlayer.Changed:connect(function (property)
- if (property == "Character") then
- onPlayerRespawned(newPlayer)
- end
- end)
- end
- game.Players.ChildAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement