iOS Raycast question...

Hello. I want to destroy an object if the player taps on it with their finger. I have attached he following script to the object (I got it from here) and I am running into a problem. The object is destroyed whenever I touch the screen at all (regardless of where I touched the screen in relation to the object). What am I doing wrong? Thanks

function Update () {
	// Code for OnMouseDown in the iPhone. Unquote to test.
	var hit : RaycastHit;
	for (var i = 0; i < Input.touchCount; ++i) {
		if (Input.GetTouch(i).phase == TouchPhase.Began) {
		// Construct a ray from the current touch coordinates
		var ray = camera.main.ScreenPointToRay (Input.GetTouch(i).position);
		if (Physics.Raycast (ray,hit)) {
			hit.transform.gameObject.SendMessage("OnMouseDown");
			Destroy(gameObject);
	      }
	   }
   }
}

This code will destroy the game object it is attached to any time your ray hits anything in the scene. So if you have a background plane, or other game objects…anything with a collider…you will destroy the game object this script is attached to.

You can check what it is hitting by putting this on line 10:

Debug.Log(hit.collider.name);

I don’t know how you want to structure your game, but you may want to have this code destory what is hits rather than the game object the script is attached to:

Destroy(hit.collider.gameObject);

Or you may want to check the name or the tag before destroying:

if (hit.collider.name == "Target") {
    Destroy(hit.collider.gameObject);
}