Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Radstar1 270 Moderation Voter
4 years ago
Edited 4 years ago

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.

Ad

Answer this question