Scripting Error? Type TRUE cannot be compared to FALSE

  1. Trying to create a debounce of some sort to check if its true or false for the motors to move

  2. Where it says “elseif down == false then” it says “Type TRUE cannot be compared to FALSE”
    error

  3. Ive tried searching this problem up on the devfourm with no luck

local equipped = false
local tool = script.Parent
local down = true

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local Plane = if player.Character then player.Character:FindFirstChild("Plane") else nil

local MainPart = Plane.MainParts


local UIS = game:GetService("UserInputService")

tool.Equipped:Connect(function()
	equipped = true
	print("EQUIPED")
	if equipped == true and down == true then
		UIS.InputBegan:Connect(function(input)
			if input.KeyCode == Enum.KeyCode.G then
					down = false
					MainPart.Main.LGFMotor.DesiredAngle = 1.5
					MainPart.Main.LGRMotor.DesiredAngle = -1.5
					MainPart.Main.LGLMotor.DesiredAngle = -1.5
					print("DOWN")
			elseif down == false then
				if input.KeyCode == Enum.KeyCode.G then
					MainPart.Main.LGFMotor.DesiredAngle = 0
					MainPart.Main.LGRMotor.DesiredAngle = 0
					MainPart.Main.LGLMotor.DesiredAngle = 0
						down = false
						print("UP")
				end
			end
		end)
	end
end)

tool.Unequipped:Connect(function()
	equipped = false

end)

I know my code is messy but im going to fix it later just right now i dont understand how to fix it and what the problem. When i click g it says print "DOWN"which is does but when i click g again it just prints "DOWN"again when it should say “UP” and the motors to change?

1 Like

You’re checking if down is false in a block where down is guaranteed to be true.

if equipped == true and down == true then -- The below code will only execute if down is true...
		UIS.InputBegan:Connect(function(input)
			if input.KeyCode == Enum.KeyCode.G then
					down = false
					MainPart.Main.LGFMotor.DesiredAngle = 1.5
					MainPart.Main.LGRMotor.DesiredAngle = -1.5
					MainPart.Main.LGLMotor.DesiredAngle = -1.5
					print("DOWN")
			elseif down == false then -- This elseif is in the wrong block... how could down be false?
				if input.KeyCode == Enum.KeyCode.G then
					MainPart.Main.LGFMotor.DesiredAngle = 0
					MainPart.Main.LGRMotor.DesiredAngle = 0
					MainPart.Main.LGLMotor.DesiredAngle = 0
						down = false
						print("UP")
				end
			end
		end)
	end
2 Likes

How am i able to fix this then if you wouldnt mind helping?

1 Like

Once g has been pressed i need DOWN to be from true to false and if its false and i click g again they chnage

1 Like

try

local equipped = false
local tool = script.Parent
local down = true

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local Plane = if player.Character then player.Character:FindFirstChild("Plane") else nil

local MainPart = Plane.MainParts

local UIS = game:GetService("UserInputService")

local debounce = false

tool.Equipped:Connect(function()
    equipped = true
    print("EQUIPPED")
    UIS.InputBegan:Connect(function(input)
        if input.KeyCode == Enum.KeyCode.G and not debounce then
            debounce = true
            if down then
                MainPart.Main.LGFMotor.DesiredAngle = 1.5
                MainPart.Main.LGRMotor.DesiredAngle = -1.5
                MainPart.Main.LGLMotor.DesiredAngle = -1.5
                down = false
                print("DOWN")
            else
                MainPart.Main.LGFMotor.DesiredAngle = 0
                MainPart.Main.LGRMotor.DesiredAngle = 0
                MainPart.Main.LGLMotor.DesiredAngle = 0
                down = true
                print("UP")
            end
            wait(0.5) 
            debounce = false
        end
    end)
end)

tool.Unequipped:Connect(function()
    equipped = false
end)

1 Like

You are a life saver thank you very much it worked!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.