I posted a question a while back on why my Level Up script wasn't working, and someone basically rewrote me a whole script from scratch, but didn't explain how it works.
I'm not sure how it works, and actually I don't think it does work. If someone could explain IN DETAIL how it works, especially the part I've highlighted in comments, I would really appreciate it. Thanks!
local xps = {0,3, 6, 10, 15, 20, 25, 30, 40, 50,
65, 80, 95, 110, 125, 140, 155, 180, 210,
250, 300, 350, 400, 450, 500, 575, 650, 725,
825, 1000};
-- Just a list (divided by 100 to be smaller)
function experience()
Player = game.Players.LocalPlayer;
local xp = Player.Exp.Value;
for level = 1, #xps do
if xp >= xps[level] * 100 then --I'm not sure what the square brackets do here
Player.leaderstats.PlayerLevel.Value = level; --I've never seen semicolons used in Rbx Lua?
end
end
Player.HP.Value = 200 + 100 * Player.leaderstats.PlayerLevel.Value;
end
function health()
Player.Character:WaitForChild("Humanoid").MaxHealth = Player.HP.Value
end
while true do --This was my attempt at looping the functions, I'm not sure if it works like this though.
experience()
health()
end

1 comment
Yeah, I know about the health and stuff, as I wrote that part, but thanks.