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

Can you have more than one else?

Asked by 10 years ago

So I have a script that 2+2 = 6. (Not true) but the script is like, 2+2 = 6. and if 2+2 == 6 then it'll print something. I'll give the script.

-- 2+2 = 6
if (2+2 == 6) then
    print("Yay I am right! 2+2 is 6.")
else
    print("Ah shucks, it's 4, not 6! D:")
else
    game.Workspace.Roboy5857.Humanoid:destroy()
    print("Ha it is 6. Told ya Roboy!!!")
end

So it's basically, if 2+2 =6 print Yay I am right! 2+2 is 6. If now it'll print Ah shucks, it's 4, not 6! D: If they are both wrong it will destory Roboy5857's. then say Ha it is 6. Told ya Roboy!!!. So there is 2 else's in this script. Is that possible?

By the way, it says line 6 is wrong.

0
They can't "both" be wrong, because "else" is just everything except the first condition. BlueTaslem 18071 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

you could do something else, but no you can not have two "else"'s in a script You could do:

if(2+2=6) then
 print("Yay I am right! 2+2 is 6.")
game.Workspace.Roboy5857.Humanoid:Destroy()
    print("Ha it is 6. Told ya Roboy!!!")
elseif(2+2 =4 ) then
  print("Ah shucks, it's 4, not 6! D:")
end
Ad

Answer this question