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
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?