Hello I tried to make a script that when you level up you gets one more maxhealth. PROBLEM: if player has more xp it goes example: you are 4 level gets 1000 xp and now level 7 you skiped level 5,6 so it means you didn't get that + 1 max health. How can I make sure you get at every level even you skipped some of them. Gets + 1 like level 1 = 100 MaxHealth, level 7 = 107, level 200 = 300. Something that checks each time as a level get up.
script is not a local script but still inside the playergui.
I hope my question is understandable.
wait(2)
local player = script.Parent.Parent
local unlock = player.leaderstats.Level
local MH = player.leaderstats.Vis01 -- max health
local S = player.leaderstats.Vis02 -- max speed
local J = player.leaderstats.Vis03 -- max jumppower
local check = player.leaderstats.Vis04
while true do
wait(2)
-- problem --
if unlock.Value == 2 and check.Value == 1 then
MH.Value = MH.Value + 1
check.Value = check.Value + 1
end
if unlock.Value == 3 and check.Value == 2 then -- check is only here for preventing loops or when player rejoin they don't get a double maxhealth (check value does save too)
MH.Value = MH.Value + 1
check.Value = check.Value + 1
end
-- ETC...
if unlock.Value == 20 and check.Value == 19 then -- works
S.Value = S.Value + 1
check.Value = check.Value + 1
if unlock.Value == 25 and check.Value == 24 then -- works
J.Value = J.Value + 1
check.Value = check.Value + 1
end
end
end
Thank you

2 comments
No, now it goes up every two seconds
Also their were already two errors in your script "if" needs a then and you forgot a end.