Boolean false doesn't get detected

So I need to see if true gets detected and it does.
But when I check for false it does not. I tried if not elseif else, I tried everything.

-- 
local function CheckForLazer()
	for i,v in pairs(Lazer:GetChildren()) do
		if v:IsA("Part") then
			IsLazerBought.Changed:Connect(function(bought)
				if bought == true then
					v.Transparency = 0
					IsLazerActive.Changed:Connect(function(active)
						if active == true then
							print(active)
						elseif not active then
							print("not active")
						end
					end)
				end
			end)	
		end
	end
end

CheckForLazer()

only prints active if true, else ignores if false.

local function CheckForLazer()
	for i,v in pairs(Lazer:GetChildren()) do
		if v:IsA("Part") then
			IsLazerBought.Changed:Connect(function(bought)
				if bought == true then
					v.Transparency = 0
				end
			end)	
			IsLazerActive.Changed:Connect(function(active)
				if active then
					print(active)
				else
					print("not active")
				end
			end)
		end
	end
end

CheckForLazer()

doesn’t work, it prints true(x6) times.
I did try else statement it was a bit different structure, but welp.

can u show me how is the active value is changing?

Is this a boolvalue object?

StianValkyrie

Oh change to this

-- 
local function CheckForLazer()
	for i,v in pairs(Lazer:GetChildren()) do
		if v:IsA("Part") then
			IsLazerBought.Changed:Connect(function(bought)
				if bought == true then
					v.Transparency = 0
					IsLazerActive.Changed:Connect(function(active)
						if active == true then
							print(active)
						elseif active == false then
							print("not active")
						end
					end)
				end
			end)	
		end
	end
end

CheckForLazer()

Did my solution work @StianValkyrie ?

hello, no it doesn’t work, coz I put boolean value, and it checks bool, like inside game, without it, it doesn’t works, I also been a dummy and deleted my old save file, now all I have to do is reconstruct it a bit.

so no it didn’t work, thanks for answering.

Then you’ll need to check if the bool exists

Assume this is your bool

local bool = Model:Waitforchild(“BoolValue”, 20)
if not bool then return end

This will make the script wait for the bool to exist for 20 seconds
I’m assume the code is in a function which relies on the bool, so it’s safe to terminate the function completely if for some reason the bool is gone.

However, the reason why your bool is disappearing is a separate issue to your original question. If the bool is supposed to always be in the same location WaitForChild is the appropriate method. If there are multiple instance that may or may not contain a bool of a particular name, you’ll need to check first if the bool exists, and if not you could use Instance.new to make one.

I would prefer you open a new topic for this, but if you want it fixed in this thread, post the script and explain your issue.