Need help with a misleading Error

Hey! I have a script that is generating this error:

And here is the part of the script that I need help with:

local maxDistance = startDirection.Magnitude
	local direction = startDirection.unit
	local lastPosition = startPosition
	local distance = Instance.new("NumberValue")
	distance.Value = 0
	local ignore = {}

	local hit, position, normal

	local Blacklist = RaycastParams.new()
	Blacklist.FilterType = Enum.RaycastFilterType.Blacklist
	Blacklist.FilterDescendantsInstances = ignore
	while true do
		if not distance.Value >= maxDistance - 0.1 then -- It errors here. As you can see, none of these are booleans.
			if not (hit and hit.CanCollide) then
				distance.Changed:Wait()
			end
		end
	end

Looks like it’s evaluating (not distance.Value) into a boolean. Try parenthesis around it like:

if not (distance.Value >= maxDistance - 0.1) then...
2 Likes

lol i was just about to do that

1 Like