I'm watching some tutorials and they use elseif, and I don't know what it is, because they don't explain it, and I can't find tutorials that explain what is elseif used for.
✓ ANSWER ACCEPTED
What is the difference between else and elseif?
1 answer
✓ Accepted answer
The simple answer is that the else block will run if no other blocks ran and a elseif block will be evaluated if the previous did not run.
Now some examples ........
using else
local run = true
if run then
print('runs only if truthy')
else
print('runs if the above did not run')
end
using elseif
local run = true
local run2 = true
local run3 = true
if run then
print('run first')
elseif run2 then
print('the above did not run. run must be falsy')
elseif run3 then
print('you can chain as many as you want but only the first one that evaluate to true will run')
else
print('none of the above ran')
end
The above are just some testing setups you can run and turn the variable from true to false.
Also take a look at how Lua treats type as either true or false her
I hope this helps. Please comment if you have any other questions about this code.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You made a spelling mistake^•^. I accepted this answer because this give’s an explanation of the question asked with a following example