Why does Anti-Part Insertor not work?

I made this anti-part insertion script.

-- Anti part inserton
if Anti_PartInsertor == true then
	wait(20)
	game.Workspace.ChildAdded:Connect(function(Obj)
		if Obj:IsA("Part") then
			Obj:Destroy()
        end
    end)
end

Doesn’t work.

Try Obj:IsA("BasePart") instead of Obj:IsA("Part")?

Should I run it in a while loop as well?

Having events in a loop can break things. You can do this:

-- Anti part inserton
if Anti_PartInsertor == true then
	wait(20)
	game.Workspace.ChildAdded:Connect(function(Obj)
		if Obj:IsA("BasePart") then
            print("part destroyed")
			Obj:Destroy()
        end
    end)
end

I would not make an “anti-exploit” for stuff like adding parts since the part would be destroyed even if the part is important to the game and added by your other code. Also I don’t see how a part would break the game for others. I would just focus on server-side anti-exploit since an exploiter can easily circumvent ones placed locally it in a million ways.

1 Like

Yep, you are actually right on that one, my brother adviced me as well about that.