AI Created my Raycast script, need help finishing it


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, startDirection)
	local maxDistance = startDirection.magnitude
	local direction = startDirection.unit
	local lastPosition = startPosition
	local distance = 0

	local result

		local ray =, direction * (maxDistance - distance))
		result = game.Workspace:Raycast(ray.Origin, ray.Direction --[[maxDistance - distance]])
		if result then
			if not result.Instance.CanCollide then
				-- No equivalent to ignore list in Raycast, so you will have to find a different way to handle this
		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

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{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)
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:
WeirdJeep.rbxm (63.6 KB)

This is an effort to rewrite the Jeep.