Mass delete of any part or mesh that has transparency = 1, recommend script or plugin

Hi,

Can anyone recommend a script or plug in that will go through the workspace and delete all parts / meshes / special meshes, that have transparency set to 1? (but not other things that have the transparency property )

So like a mass search and delete. OR perhaps a rename of the thing it finds.

Thanks.

for _, child in ipairs(workspace:GetDescendants()) do
	if child:IsA("BasePart") then
		if child.Transparency == 1 then
			child:Destroy()
		end
	end
end

What you’re trying to do could crash your studio/lag depending on the size of your game. But, here is what you are looking for:

for i,inst in pairs(workspace:GetDescendants()) do
    pcall(function()
        if inst.Transparency==1 then
            inst:Destroy()
        end
    end)
end

As you see, I used a pcall function to reduce the usage of if statements.

If you want delete this in studio use command console.

Calling pcall() on every instance iterated over is going to cause a lot of overhead.

He is executing this in studio I realized.

ya, in studio, ok, thanks for the input, I’ll try it out.

What? Can you explain how this is productive at all? You can just do if inst:IsA('BasePart') and inst.Transparency == 1

MeshParts are not considered BaseParts. I didn’t feel the need to put effort into all of the if conditions because he is just using the script in the studio command bar.

Actually, MeshParts are BaseParts. You’re probably thinking of normal Parts, not BaseParts.

1 Like

You’re probably thinking of normal Parts.

All Parts/MeshParts/Unions extend BasePart.

Sorry, I was thinking about clarifying but I was AFK. I mean they were thinking about how MeshParts don’t inherit from Part.

There’s no way that a separate function call is more efficient then one if statement.

Again, the efficiency doesn’t matter for this situation because he is simply looking for something to run into the Studio command bar quickly.

And yes, I am aware if this were to be implemented into the game it would need adjustments because it would cause a lag, but for something to simply run into the command bar as a shortcut, this should be fine as well as many other codes.