Elseif is pretty much what it seems like. It's an else and if statement combined. The difference between elseif and else is kind of hard to explain without showing some code. Here's my best explanation:
if value == 5 then
print"yay its 5!"
else
print"not 5"
end
The code above would print "yay its 5!" if "value" is equal to 5. If the value is anything else, it will print "not 5."
if value == 5 then
print"yay its 5!"
elseif value == 4 then
print"meh, its 4"
end
The above code snippet would print "yay its 5!" if "value" is equal to 5, and print "meh, its 4" if "value" is equal to 4. You could technically do this:
if value == 5 then
print"yay its 5!"
else
if value == 4 then
print"meh, its 4"
end
end
It's generally better to use elseif instead of using "else" and "if" separately, because you don't need another end with elseif, and using elseif is much easier to use if you have multiple conditions.
You can also combine elseif and else.
if value == 5 then
print"yay its 5!"
elseif value == 4 then
print"meh, its 4"
else
print(value.." is not good enough!"
end
You can read more on conditional statements here.
I hope this answer helped you. If it did, please upvote and accept!
3 comments
Nice formatting (not sarcasm).
Thank you guys!
Thank you, yumtaste. You're welcome, TheContinentofEurope.