In the following script, collision is not being detected. Why?

function OnCollisionEnter(col:Collision){
if(col.gameObject.name == “t”){
Debug.Log(“detected!”);
xp += 97;
xp_Component.text = “” + xp;
}
else if(col.gameObject.name ==“Target”){
xp +=30;
xp_Component.text = “” + xp;
}
}

For collision to work, both of of your colliding objects must have a collider attached to them, and one of them must have a rigidbody component. See this video from Unity.