OnCollisionEnter Stopped Working

Okay, so I had code working for a Snake game in which, like the classic, you pick up an object, the score goes up and if you hit your tail or a wall it’s Game Over. But for some reason now the food does not destroy itself when picked up. I know I am hitting the food as the score goes up but the food doesn’t disappear then reappear.

Here is my collision code:

var player : GameObject;
var food : GameObject[];
var Tail : GameObject;
var lastTail : GameObject;




function Start () {

}

function Update () {

}
	
	function OnCollisionEnter (collision : Collision)
	{
		
		if(collision.transform == player)
			
	{
		
			addTail ();
			Destroy(gameObject);
		
	
	var foodname	= Instantiate(food[(Random.Range(0,food.Length))],
		 new Vector3(Random.Range(-48, 96), 1.5, 
		 Random.Range(-23, 22)), 
		 Quaternion.identity) as GameObject;
		 
		 foodname.name = "Food";
        
	}
	}
	
	function addTail ()
	{
	var newTail : GameObject = Instantiate(Tail, transform.position, Quaternion.identity);
	newTail.name = "Tail";
	newTail.GetComponent.<SmoothFollow>().target = lastTail.transform;
	lastTail = newTail;
	}

first script belongs to which object ? player ?

 function OnCollisionEnter (collision : Collision)
    {
      if(collision.transform == player)
         {
              addTail ();
              Destroy(gameObject);
             var foodname   = Instantiate(food[(Random.Range(0,food.Length))],
             new Vector3(Random.Range(-48, 96), 1.5, 
             Random.Range(-23, 22)), 
             Quaternion.identity) as GameObject;
             foodname.name = "Food";
         }
    }

as i know , you said here “just when player hit itself, destroy itself” .
i don’t see food destroy cod in your script !!!

i think you should change :

 if(collision.transform == player)

to this :

 if(collision.gameObject.name == "Food") 
    Destroy(collision.gameObject);

** Just if this script attached to Player.