need help to destroy game object

hello all i got this scrip and iv been trying all day to make it when the gameObject.tag == "player" collides with the object its destroys the gameObject please help me

private var destroy = false;

function CharacterController (hit : Collider)
{
     if(hit.gameObject.tag == "player")
     {
        destroy = true;
     }
}
function DestroyNow()
{
    DestroyObject (gameObject);
}

You don't need the boolean or separate function. This code will immediately destroy the gameObject that collides with the player object.

function OnControllerColliderHit (hit : ControllerColliderHit)
{
     if(hit.gameObject.tag == "player")
     {
        Destroy(gameObject);
     }
}

I find the Unity Script Reference is a great resource for checking syntax. It also usually has a helpful example for the specific code. If you search "CharacterController", you'd find the correct syntax for the OnControllerColliderHit function. Worth a try in future.

Hope this helps! If you don't understand, feel free to comment back.