Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I delete all instances with the same name?

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

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.