How to make Raycast ignore certain parts by name

Basically, I’m trying to make it so swordphin123’s raycast system ignores HumanoidRootParts, but the only way to ignore parts is through a folder/table. Is there any way to get it to ignore parts by certain criteria (for example, if hit.Name == “HumanoidRootPart” then ignore) using the new raycast?

You can find them by using something like Instance:GetChildren() or Instance:GetDescendants().

local function getIgnoreList(container)
	local ignoreList = {}
	for _, descendant in pairs(container:GetDescendants())
		if descendant.Name == 'SOMETHING' then
			table.insert(ignoreList, descendant)
		end
	end
	return ignoreList
end

I do not know how swordphin123’s raycast system works, but you can specify an ignore list with RaycastParams.

2 Likes