Problem with (attempt to compare number <= boolean)

Hello
I have a problem, when a player zooms in with raycast with magnitude and then I move away, sometimes I get an error about (Attempt to compare number with boolean?)
there I leave a capture in Output
image
there the blue line says a fault

Script :
game:GetService(“RunService”).RenderStepped:connect(function()

for i,v in ipairs(workspace.Zona_iluminacion:GetChildren()) do
	if v:FindFirstChild("Luz") and not Iluminada then
		
		local R            = v.Luz
		local ray  = Ray.new(R.Position , jugador.Character.HumanoidRootPart.Position-R.Position)
		local now  = workspace:FindPartOnRay(ray,v)
		
		if now then
			if now.Parent:FindFirstChild("Humanoid") or now.Parent.Parent:FindFirstChild("Humanoid") then
				if (R.Position - jugador.Character.HumanoidRootPart.Position).magnitude <=15 then 
					print("hola misuja!")
					Iluminada=true
					repeat wait() until not now.Parent:FindFirstChild("Humanoid") and (R.Position - jugador.Character.HumanoidRootPart.Position).magnitude >=15 or not now.Parent.Parent:FindFirstChild("Humanoid") and not (R.Position - jugador.Character.HumanoidRootPart.Position).magnitude >=15
					print("adios misu...")
					Iluminada= false
				else
					Iluminada = false
				end
			else
				Iluminada = false
			end
		else
			Iluminada = false
		end
	end
end

Is there a way like fixing the bug? :frowning:

1 Like

What line is erroring? I can’t tell from the screenshot.

It says :59, line 59. 30karster

try putting parenthesis around
(R.Position - jugador.Character.HumanoidRootPart.Position).magnitude >=15

2 Likes

the screenshot did not contain the lines and the code he posted obviously does not have 59 lines either

Right, I only checked the error, my bad.


I think it is so, but I thank you very much! :cat:

2 Likes