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

Simple "or" operator question?

This is a pretty basic question, but I've just been wondering. If I use an or operator to check if, for example, value a or b are true.

if a == true or b == true then
print("Done")
end

Would that print "Done" if BOTH are true at the same time? It's just something I never learned.

Thanks!

1 answer

✓ Accepted answer

Yes

When you look at a conditional statement, read it from left to right.

Using your example...

If the first one is true in an or statement, it has no need to check the second part of the statement. So it prints. If it were false, it would then go ahead and check the second part.

Now, if it was an and, it would check from left to right to see if both of them were true before printing. If the first one was false, then it would not bother checking the second one.

1 comment

0

Ah, thanks! That's what I thought.

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