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
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
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.
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.
3 comments
Alright, I understand now. So does saying 'if not Value' basically mean 'if Value == false' ?
Right!
Thank you much!