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

How to destroy all Parts with a specific name?

Asked by 5 years ago
Edited 5 years ago

how to destroy all parts with the name "Test"?

(not only in workspace but also in models in workspace)

1 answer

Log in to vote
1
Answered by
Despayr 505 Moderation Voter
5 years ago
Edited 5 years ago
local descendants = game.Workspace:GetDescendants()

-- Loop through all of the descendants of the Workspace. If a
-- BasePart is found, the code changes that parts color to green
for index, descendant in pairs(descendants) do
    if descendant.Name = "Test" then
        descendant:Destroy()
    end
end
Ad

Answer this question