So, I'm trying to make it so you have an overall experience, and you level up whenever that hits a certain point(that I set for each)
For example:
Rank 1 - hit 0 XP(obviously) Rank 2 -100 XP Rank 3 -250 XP rank 4 - 750 XP
I tried something like this:
if xp.Value <= 0 then if xp.Value <=100 then --code else --level 0? end end
I think elseif may be what you’re looking for with something like this:
local rank = 0 if xp.Value < 100 then rank = 1 elseif xp.Value < 250 then rank = 2 elseif xp.Value < 750 then rank = 3 end print(rank)
To make reading conditionals (if
statements) and their blocks easier, make sure to properly indent your code. It seems like you might need a bit more practice with conditionals, so if you haven't already, read through this wiki page about conditional statements. In any case, I've indented and commented your code to help understand what you've got. I hope it helps, and doesn't make things more confusing for you:
if xp.Value <= 0 then -- "xp.Value is <= 0" -- The below conditional is useless because the condition -- will always evaluate to true as long as we're in -- this code block: this means line 09 will always run -- and line 11 will never run. if xp.Value <=100 then -- "xp.Value is <= 0 and also <= 100" else -- "xp.Value is <= 0 and is > 100" end -- "xp.Value is <= 0" end