Often, I when clearing specific objects I use :GetChildren() and cycle through all the objects returned to remove a specific object type. I think it would be really useful to add an optional argument to set an instance type. So if you said Head:ClearAllChildren(“Sound”) it would remove all sound in the head.
Supports for you!
Edit: Also, would it be recursive or not?
Perhaps :ClearAllChildren( [Instance Type], [boolean isRecursive] )?
i thought about something similar with GetChildren, but thought that might be bad practice
ClearAllChildren(model,type,recursive) for _,i in pairs (model:GetChildren()) do if i:IsA(type) then i:destroy() elseif recursive then ClearAllChildren(i,type,recursive) end end end
@Space: I have a recurse function saved to my desktop because I use it so much :DDD
function recurse(root,callback) for i,v in pairs(root:GetChildren()) do callback(i,v) if #v:GetChildren() > 0 then recurse(v,callback) end end end
recurse(workspace, function(i,v) if v.Name == "KILLME" then v:Destroy() end end)