Is there is a script for if false then

i write a script that has if false then and when i tested the game it didn’t show up in developer console and didn’t print what i need to print and the same thing with printing the statement is false. there is a picture of the script


there is a picture of developer console

1 Like

if x == false then or if not x then

3 Likes

If you do “if false then” your basicly checking wondering if false is true. and false is not true so it wont print. Idk what your trying to do but you need to check the false with another value like if false == false then or if game.workspace.yourvalue.Value then

2 Likes

There are two ways you can go about this

First Example:

local FirstVar = false

if FirstVar == false then
	Print("FirstVar is false! (First example)")
end

-- And the same for true

if FirstVar == true then
	Print("FirstVar is true! (First example)")
end

Second example:

local SecondVar = true

if not SecondVar then  -- "if not [VarName] then" Essentially will check for false when the var is a bool.
	Print("SecondVar is false! (Second example)")
end

-- And the same for true

if SecondVar then -- "if [VarName] then" Essentially will check for true when the var is a bool.
	Print("SecondVar is true! (Second example)")
end

If you need more help refer to the official documentation here.

2 Likes

The philosophy behind if statements is to check whether a condition is true before executing a block of code: this condition can be a simple value or a comparison.

Your code is not running because the value false is, well, by definition, false. An if statement with the condition false will not run the associated code block

Therefore, in this specific case where the variable itself is set to false , you need to explicitly check if the value is equal to false:

local value = false
if value == false then -- checks: "is this false?" yes, it is
   -- code
end 

Alternatively, you could use the not operator to check if the value is not true (which is the same as checking if it’s false)

local value = false
if not value then -- checks: "is this not true?" yes, it is not true
   -- the code here will also run
end
2 Likes

If is followed by a condition check, and if that condition is true, the code block executes.

---------------
local v = true
---------------
if v == true then
end

if v then
end

if true then
end

---------------
local v = false
---------------
if v == false then
end

if not v then
end

if v ~= true then
end
1 Like

Instead of saying if false then, which ur basically checking if “false” is equal to true, do if false == false, which means basically what it’s saying. If false is false, then it’s true.

1 Like