# Destroying anything, after a moving trigger box exits it

I'm making a endless runner game, and i have a trigger box following the character, behind the camera. I want it to destroy any kind of object, after the trigger box exits the object. so far i have written this for the code, but it doesn't seem to be correct, and actually doesn't work!

 void OnTriggerExit (Collider other)
{
Destroy(other.gameObject);
}


What should i add to this? Thanks.

In order for OnTriggerExit() to work, at least one of the game objects involved in the collision must have a rigid body component attached.