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

What does this mean in an If statement?

This is probably a very basic question... if not gameThing and gui.Visible then

How does this work? I thought when using variables in an if statement, you need to specify a determinant. Example: if gameThing ~= nil and gui.Visible == false then

2 answers

✓ Accepted answer

The way that if statements work is that they takes a conditional statement and either execute the following block of code if the condition is true, or skip it if the condition is false.

So essentially you could say if true then and it would always execute the code block. Same goes for if false then, except it would never execute the code block. All that is required for the if statement condition is that it evaluates to a boolean (true/false) value.

3 comments

0

Alright, I understand now. So does saying 'if not Value' basically mean 'if Value == false' ?

0

Right!

0

Thank you much!

Following BlackJPI's explanation, not x evaluates to true if and only if x is neither nil or false. Since nil represents a lack of useful value (nothing), you can use this to test whether a value exists.

So if not gameThing and gui.Visible then would mean if gameThing exists (and is not explicitly false) and gui is Visible then do the following.

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