How to blacklist elements in a table for raycasting (Closed Topic)

To start, the purpose of the script is to let bricks detect ceiling, but it doesnt ignore anything that has a humanoid so ive been trying to achieve that the ray ignores all of the parts that are in a table but i havent been able to achieve it

I did actually manage to do the table but i havent been able to insert the elements of the table into the blacklist, usually it just gives me the error
Infinite yield possible on ‘Workspace:WaitForChild(“{}”)’

while wait() do
	local safeParts = {}
	local rayOrigin = script.Parent.Position
	local rayDirection = Vector3.new(0, 10, 0)
	local raycastParams = RaycastParams.new()

	for i, v in pairs(game.Workspace:GetChildren()) do
		local hum = v:FindFirstChild("Humanoid")
		if hum then
			table.insert(safeParts, v)
			print("good2")
		end
	end
	
	raycastParams.FilterDescendantsInstances(game.Workspace:WaitForChild(safeParts))
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
	
	if raycastResult then
		local hitPart = raycastResult.Instance
		local hum = hitPart:FindFirstChild("Humanoid")
		if hitPart ~= nil and hum == nil then
			print("good")

		end
	end
	
end

I’d gladly appreciate any help or comments on this

1 Like

You’re searching for a table and not for the part itself.
Instead you could do a for loop and loop through every part inside the table.
And as you didn’t put anything inside “safeParts”, it will just say

Infinite yield possible on ‘Workspace:WaitForChild("{}")’

But as you’re not trying to do that, I suggest changing this line:

raycastParams.FilterDescendantsInstances(game.Workspace:WaitForChild(safeParts))

to

raycastParams.FilterDescendantsInstances(safeParts)

image

Oh, wait I see what you did wrong,

raycastParams.FilterDescendantsInstances(game.Workspace:WaitForChild(safeParts))

You’ve to make it equal to something it’s not an event/function so it’d be:

raycastParams.FilterDescendantsInstances = safeParts

Golly gee thanks for the help mate

Could you close the topic now that you got your solution, thanks! :smiley: