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

Can you have more than one else?

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.

1 comment

0

They can't "both" be wrong, because "else" is just everything except the first condition.

1 answer

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

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