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

Remove ALL Models in a set

I want to make it so when you click a button in a Gui, it removes all the Chairs in a Model named "Set". But I remember it not working, does anyone know how to do this if all the Models are named the same?

2 comments

0

You know, you're just downing EVER answer that comes. We're here to help and every one of our scripts works. You never said you wanted it to regen. You JUST changed it to a GUI. Honestly, just stop. We're all helping and you're just downing us because YOU believe we're getting the scripts wrong. Stop changing what you want and just edit one of ours.

0

New Forum

2 answers

function clear(parent, name)--Parent is the model to be searched, name is the name of the thing to be removed (as a string)
	for i, v in pairs(parent:GetChildren()) do
		if v.Name==name then
			v:Destroy()
		end
	end
end

local model = Workspace.Set

local function clearChairs(dir)
	for i,v in pairs(dir:GetChildren()) do 
		if v.Name == "Chair" then
			v:Destroy()
		end
		clearChairs(v)
	end
end

clearChairs(model)

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