gameObject wont destory on mouse click

I typed up this Java script thinking it would work on collision but I won’t. My enemy prefab is tagged as a “Wall” like said in the script, and my script is connected to my player.

Here is my script:

var prefab : GameObject;

function OnCollisionEnter(collision : Collision){

        if (collision.gameObject.tag == "Wall")


OnCollisionEnter() is only being called once, that is when the two GameObjects collide. With your code you have to press the firebutton right at the moment the collision occurs - which practically is impossible. You might want to just use OnCollisionStay() instead or remove the code where you have to press a key while the collision occurs - or just find another way around. I of course don’t know the purpose of this and how you want it to work.

Let me know if this helped, and anybody can feel free to correct me.