On collide, destroy Game Object

OK first of all I must apologise for asking what has been asked probably a million times before, I just can’t get the solution I need. The game I’m creating for an assignment has enemy spaceships which spawn and fly past the player. I’ve been trying to write a javascript code so that once they fly to a certain point (a cube the player can’t see) they are removed from the game. I’ve tried different combinations, this was the last one I used:

    function OnCollisionEnter(collision : Collision)
{
    Destroy(collision.gameObject);
}

and I tried it on both the spaceship and the cube and nothing works, everything I try the spaceship flies towards it and just remains there.

Can anyone offer advice for me please?

Is the function actually being run? Put

Debug.Log("OnCollisionEnter"); 

in the function and see if it’s actually being called at all.

If it’s not make sure the spaceship or the cube both have colliders.
Make sure they both have size in all dimensions.
Make sure the spaceship actually enters the cube.
Make sure the trigger option on either collider is not checked. If it is then you’ll need to use this function instead.

function OnTriggerEnter( collider : Collider )
{
    Destroy(collider.gameObject);
}

If it’s still not working then make sure the object layers are not filtered from each other. Check Edit → Project Settings → Physics and make sure the check box representing their two layers collision is checked.