Destroying multiple objects at once

Which is faster and better?
Option 1:

for _ = 1, math.random(4, 6), 1 do
    local Clone = SomeObject:Clone()
    DoStuffWith(Clone)
    Clone.Parent = workspace
    Debris:AddItem(Clone, 1)
end

Option 2:

local Folder = Instance.new("Folder", workspace)
Debris:AddItem(Folder, 1)
for _ = 1, math.random(4, 6), 1 do
    local Clone = SomeObject:Clone()
    DoStuffWith(Clone)
    Clone.Parent = Folder
end
2 Likes

I dunno what you are trying to achive but :ClearAllChildren() might help you out.

I wouldn’t recommend Option 2 since you don’t know how long DoStuffWith(Clone) will take to complete and not every Clone would be added to the folder if the function takes too much time

1 Like

Not a problem if DoStuffWith is non yielding

1 Like