Click to destroy object

I need a script so that when the mouse clicks directly on an object, it is destroyed. Here is what I've got so far..

var clicked : boolean = false;
var hit : RaycastHit;
function Update() {
if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),hit, Mathf.Infinity)) {
 Destroy(gameObject,0);

}
}

Any ideas/advice?

P.S. Sorry I've been putting up so many questions this evening. This is the last one. I hope.

Put this script on the objects:

function OnMouseDown () {
    Destroy(gameObject);
}

Hi,

You can use this code in the objects update method:

public class DestroyPlayAudio : MonoBehaviour
    {
        public AudioSource audioSource;
        public AudioClip clip;
        public float volume=0.5f;
    
        void Update()
        {
             if (Input.GetButtonDown ("0")) 
            {
                Raycast ray=Camera.main.ScreenPointToRay(Input.mousePosition);
                Raycasthit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    Destroy(hit.collider.gameObject);
                    audioSource.PlayOneShot(clip, volume);
                }  
            }
        }
    }

Insert your audiofile in the variable slot in the Monobehaviour.

If you want to create games fast without coding learn and use Playmaker or Game Creator.