I am fairly new to scripting, and wondering, what would the function elseif do? and how would I properly execute it? I know what else does, and can't figure out how to use elseif.
✓ ANSWER ACCEPTED
Quick Question about Elseif?
1 answer
✓ Accepted answer
First of all, elseif is not a function. It is a keyword.
The difference between elseif and else is that the former lets you specify a new condition which must be true for the block to be entered, while the latter executes if and only if all previous if and elseifs failed.
It is really just a combination of else and if:
if A then
-- do something if `A` is true
elseif B then
-- do something else if `A` is false but `B` is true
end
is equivalent to
if A then
-- do something if `A` is true
else
if B then
-- do something else if `A` is false but `B` is true
end
end
The former is clearer and should be preferred.
1 comment
0
I'd like to add that an if statement can have as many elseif clauses as you want, but can only have a single else clause located at the very end.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
http://robloxdev.com/articles/Conditional-Statements-in-Lua (Check section named "elseif")