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?
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)