Hello, Im trying to make a level script. I got the leaderboard but, how must i make that when someone gets killed it gives XP? Code:
function PlayerAdded(Player)
local stats = Instance.new("IntValue")
local xp = Instance.new("IntValue")
local lvl = Instance.new("IntValue")
lvl.Value = 1
xp.Value = 0
xp.Parent = stats
lvl.Parent = stats
stats.Parent = Player
xp.Name = "Xp"
lvl.Name = "Level"
stats.Name = "leaderstats"
if xp.Value == 120 and lvl.Value == 1 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 200 and lvl.Value == 2 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 320 and lvl.Value == 3 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 450 and lvl.Value == 4 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 580 and lvl.Value == 5 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 800 and lvl.Value == 6 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1200 and lvl.Value == 7 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1500 and lvl.Value == 8 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1850 and lvl.Value == 9 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2005 and lvl.Value == 10 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2300 and lvl.Value == 11 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2600 and lvl.Value == 12 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2950 and lvl.Value == 13 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3200 and lvl.Value == 14 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3500 and lvl.Value == 15 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3855 and lvl.Value == 16 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4000 and lvl.Value == 17 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4550 and lvl.Value == 18 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4900 and lvl.Value == 19 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 5500 and lvl.Value == 20 then
xp.Value = 0
lvl.Value = lvl.Value+1
end
local maxlvl = 20
if game.Players.LocalPlayer.stats.level > 20 then
warn(baad)
end
if sbb then
print(good)
elseif not sbb then
warn(bad)
end
end
maxlvl = 20
game.Players.PlayerAdded:connect(PlayerAdded)
sbb = game.Players.LocalPlayer:FindFirstChild("stats")
good = "A player joined and loaded succesfully!"
bad = "A player joined and haven't loaded!"
baad = "A player got more than" ..maxlvl.. "levels!"
Yeah, pretty long. I want to compress this too,
if xp.Value == 120 and lvl.Value == 1 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 200 and lvl.Value == 2 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 320 and lvl.Value == 3 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 450 and lvl.Value == 4 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 580 and lvl.Value == 5 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 800 and lvl.Value == 6 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1200 and lvl.Value == 7 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1500 and lvl.Value == 8 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 1850 and lvl.Value == 9 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2005 and lvl.Value == 10 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2300 and lvl.Value == 11 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2600 and lvl.Value == 12 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 2950 and lvl.Value == 13 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3200 and lvl.Value == 14 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3500 and lvl.Value == 15 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 3855 and lvl.Value == 16 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4000 and lvl.Value == 17 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4550 and lvl.Value == 18 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 4900 and lvl.Value == 19 then
xp.Value = 0
lvl.Value = lvl.Value+1
elseif xp.Value == 5500 and lvl.Value == 20 then
xp.Value = 0
lvl.Value = lvl.Value+1
end
But i want the max XP to increase each levels... Help please?

1 comment
P.S: I want this script to work in online mode, Im wondering how to make it work in a solo map, but i want this for a RPG map.