collsion issue

// on collsion with Darkcoin, destroy coin and add point to score.
function OnControllerColliderHit (hit : ControllerColliderHit) {
if(hit.GameObject.Sphere){
Destroy(GameObject.Sphere);
}
else {
return;
}
}

this doesnt work and i cant figure out why. I want the object to be destroyed when player collides with it and add a point to a variable that ill add later. i got the object to destroy with a simple collision hit but am trying to make it specific to collisions with the player only. Any help is appreciated thanks!

hit.GameObject.Sphere doesn’t make sense (or if it does, I don’t know it). Also GameObject.Sphere doesn’t reference the colliding object, but the object the script is attached to.

function OnControllerColliderHit (hit : ControllerColliderHit) {
    if(hit.GameObject == Sphere) {
        destroy hit.GameObject;
    }
 }

You might want to use a more specific condition in the if statement than if the colliding object is a sphere, though. For example a specific tag.