AI Created my Raycast script, need help finishing it

Greetings!

An AI Created part of my script that I really needed help with for YEARS at this point, and I am wondering how I can make an ignore list with WorldRoot:Raycast()

Here’s what I have:

local module = {}

function module.new(startPosition, startDirection)
	local maxDistance = startDirection.magnitude
	local direction = startDirection.unit
	local lastPosition = startPosition
	local distance = 0

	local result

	repeat
		local ray = Ray.new(lastPosition, direction * (maxDistance - distance))
		result = game.Workspace:Raycast(ray.Origin, ray.Direction --[[maxDistance - distance]])
		if result then
			if not result.Instance.CanCollide then
				break
				-- No equivalent to ignore list in Raycast, so you will have to find a different way to handle this
			end
		end
		distance = (startPosition - result.Position).magnitude
		lastPosition = result.Position
	until distance >= maxDistance - 0.1 or (result and result.Instance.CanCollide)
	return result.Instance, result.Position, result.Normal
end

return module

I specifically need help where it says No equivikent to ignore list in Raycast, so you will have to find a different way to handle this.

Thanks in advance!

The third parameter is raycastParams

1 Like

RaycastParams.new({object1, object2}, Enum.RaycastFilterType.Blacklist)
Do this in the 4th argument of the workspace:Raycast()

Replace object1 and object2 with a list of things you want to ignore

You can use Enum.RaycastFilterType.Blacklist for a Blacklist of the parts in the table (excludes those parts)
OR
You can use Enum.RaycastFilterType.Whitelist for a Whitelist of the parts in the table (only includes those parts)

1 Like

I tried using both Exclude and Blacklist, but for some reason, the jeep is still going down:
image
WeirdJeep.rbxm (63.6 KB)

This is an effort to rewrite the Jeep.