Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this ray casting code with the ignore list not work?

Why doesn't this work? It's supposed to make it so it only prints on grass, but it doesn't print at all?

local Ignorelist = {}
local descendants = workspace:GetDescendants()
for index, descen in pairs(descendants) do
	if not Ignorelist[descen.Name] then
		if descen.ClassName == "Part" or descen.ClassName == "MeshPart" or descen.ClassName == "Union" then
			if descen.Material == "Grass" then
				table.insert(Ignorelist, descen.Name)
			end
		end
	end
end
local ray = Ray.new(HumanoidRootPart.Position,Vector3.new(0,-10,0))
local part, endPoint, Normal, Material = workspace:FindPartOnRayWithIgnoreList(ray, Ignorelist)
if part then
	print(part.Name)
end

1 answer

Instead of putting it into a table, put a folder in workspace called ignore and add all parts you want to be ignored in there. Then take the descendants of that table and use it as the ignorelist.

This discussion is preserved as it was. New answers, comments, and votes are closed.