hello i want to delete all these parts that are all corroded material
COMMUNITY QUESTION
how to delete a bunch of parts that are the same material?
2 answers
Try this!
function destroyPartsOfMaterial(child,material)
for ind, part in pairs(child:GetChildren()) do
if part:IsA("BasePart") and part.Material==Enum.Material[material] then
part:Destroy()
end
destroyPartsOfMaterial(part,material)
end
end
destroyPartsOfMaterial(workspace,"CorrodedMetal")
You can use this for any material! Just change CorrodedMetal to the material you want!
Here's a non-recursive solution:
local Material = "Neon"
for _,part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and part.Material == Enum.Material[Material] then
part:Destroy()
end
end
1 comment
0
If you call my function on Workspace, it'll do the exact same thing this does. GetDescendants() on workspace gets all the descendants of Workspace, which is the same thing my function does.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
thank you sir