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

Remove ALL Models in a set

Asked by 10 years ago

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?

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. Shawnyg 4330 — 10y
0
New Forum xXScorpianKillerXx 25 — 10y

2 answers

Log in to vote
0
Answered by
trogyssy 221 Moderation Voter
10 years ago
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
Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

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)

Answer this question