Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

0
i tried this and it said fortnite doesnt exist (joke) User#30567 0 — 4y
0
wow, really good explanation, thanks dude. SheepeySheeps 4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question