Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the difference between "Else" and "Else If?"

I'm not sure what the difference is, can someone explain?

2 answers

✓ Accepted answer

think of it like this: say your about to send someone at the store to buy you some games, and you tell them this: if there's Fortnite then then buy it, else if there's not fortnite but there's GTA 5 then buy the GTA 5 else just buy a carton of milk.

notice here, the first if indicates the preferred choice(in the example being buy Fortnite, the else if is the second preferred case if the first case cannot be satisfied(in the example being buying GTA), the else is basically the last resort if any of the previous cases cannot be met.

another example:

if Jailbreak is better than Mad City then

Play(Jailbreak)

elseif MadCity:HasMoreContentThan(Jailbreak) then

Play(Mad City)

elseif MadCity == Jailbreak then

Play(Jailbreak)

else

print("There's no fun games on roblox")

end

put the emphasis on the fact that you can have multiple elseifs

2 comments

0

i tried this and it said fortnite doesnt exist (joke)

0

wow, really good explanation, thanks dude.

elseif (not else if) should be used when you want another condition before running code else should be used when you don't want another condition before running code

This discussion is preserved as it was. New answers, comments, and votes are closed.