How to insert a table into a rays ignore list?

So i made a pathfinding script that casts a ray to check if you are within the enemies line of sight, and if you are it moves to you’re position, otherwise it pathfinds to you, but I want the ray to ignore other enemies, I think I could do this with a table but I get an error

function checkSight(target)
	local bots = {}
	for i, v in pairs(game.Workspace:GetChildren()) do
		if v:FindFirstChild('Pathfinding') then
			table.insert(bots, v)
		end
	end
	local ray = Ray.new(humanoidRootPart.Position, (target.Position - humanoidRootPart.Position).Unit * 9999999999999999)
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent, bots})
	if hit then
		if hit:IsDescendantOf(target.Parent) and math.abs(hit.Position.Y - humanoidRootPart.Position.Y) <= 2 or string.match(hit.Name, 'Door') then
			return true
		end
	end
	return false
end

table.unpack returns a tuple which is basically a list of elements{script.Parent, table.unpack(bots)}.

1 Like