So I took this raycast script from the wiki. How can I do it so that it ignores the descendants of a model named "Potato"?
local ray = Ray.new( Weapon.Handle.CFrame.p, -- origin (mouse.Hit.p - Weapon.Handle.CFrame.p).unit * 500 -- direction ) local character1 = game.Players.LocalPlayer.Character local model = ? ignore = {character1, model} local hit, position = Workspace:FindPartOnRayWithIgnoreList(ray, ignore)
Thanks!
I am unsure of whether or not you can simply pass Models to the ignore list.
If so, just using model = workspace.Potato
may work.
Otherwise:
Using simple recursion we can get make a getParts
function by noting the following:
The descendant parts of an object are the BasePart-children of that object, as well as the BasePart-descendants of its other children.
function getParts(mod) local parts = {} for _, child in pairs(mod:GetChildren()) do if child:IsA("BasePart") then table.insert(parts,child) end for _, part in pairs(getParts(child)) do table.insert(parts,part) end end return parts end
We could then pass getParts(workspace.Potato)
.