how to destroy an object when colliding with an object other than that?

Hello, let’s suppose that in a game there is a button on the other side of the stage to be pressed, that button opens an exit that is defended by a leisure, and when that button is pressed, the leisure passage destroys! … How to make? please

There’s a lot of ways to achieve this, infinite ways of detecting how the button was pressed, and multiples ways of destroying your passage. Try to generalize your question and search that. You need a way of detecting if the button was pressed, and a way to destroy an object, you can and should search for each part separately, since you don’t know what you want. Here’s a video that talks about a similar situation.

But bear in mind that most of the times, you’ll not be able find the solution to your problem, you’ll find the path to it, so you need to adapt.