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:
1 | if xp.Value < = 0 then |
2 | if xp.Value < = 100 then |
3 | --code |
4 | else |
5 | --level 0? |
6 | end |
7 | end |
I think elseif may be what you’re looking for with something like this:
1 | local rank = 0 |
2 | if xp.Value < 100 then |
3 | rank = 1 |
4 | elseif xp.Value < 250 then |
5 | rank = 2 |
6 | elseif xp.Value < 750 then |
7 | rank = 3 |
8 | end |
9 | 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:
01 | if xp.Value < = 0 then |
02 | -- "xp.Value is <= 0" |
03 |
04 | -- The below conditional is useless because the condition |
05 | -- will always evaluate to true as long as we're in |
06 | -- this code block: this means line 09 will always run |
07 | -- and line 11 will never run. |
08 | if xp.Value < = 100 then |
09 | -- "xp.Value is <= 0 and also <= 100" |
10 | else |
11 | -- "xp.Value is <= 0 and is > 100" |
12 | end |
13 | -- "xp.Value is <= 0" |
14 | end |