What does "attempt to compare boolean with number" mean?
Here is my script:
script.Parent.Touched:Connect(function(Part) if Part.Name == "B1" and 30 < script.Parent.Parent.Parent.Car.B1.Velocity.Magnitude < 90 then print("It is B1!")
On line two, it says that I am attempting to compare a boolean with a number. What does this mean and how can I fix it?
To solve this you need to separate the comparison, like this:
script.Parent.Touched:Connect(function(Part) if Part.Name == "B1" and 30 < script.Parent.Parent.Parent.Car.B1.Velocity.Magnitude and script.Parent.Parent.Parent.Car.B1.Velocity.Magnitude < 90 then print("It is B1!") end end end)
As kingdom5 has mentioned, 30 < script.Parent.Parent.Parent.Car.B1.Velocity.Magnitude
evaluates first then it will compare it to 90.
-- 30 < 40 is true -- true < 90 errors print(30 < 40) -- Correct way if 30 < 40 and 40 < 90 then print("This works") end if 30 < 40 < 90 then print("Doesn't work") end