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

How can I delete all instances with the same name?

Asked by 4 years ago

Hello, is there a way that i can delete all parts with the same name (in a model)?

1 answer

Log in to vote
1
Answered by
JakyeRU 637 Moderation Voter
4 years ago

Hello, You have to use a for loop.

local Parts = game.Workspace:WaitForChild("Model"):GetChildren()

for _, v in pairs(Parts) do
    if v.Name == "Delete" then
        v:Destroy()
    end
end

Parts is a table with everything in the Model. The for loop will go through every element in the table checking if its name is "Delete". If yes, then it will destroy the part.

Ad

Answer this question