unity iphone raycast problem

hi guys,

i'm trying to make a game in iphone using unity3d....i'm getting trouble when i make touch on the gameobjects...

here is my script....

//.cs

public RaycastHit hit;

void Update()
{

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Input.GetMouseButtonDown(0))
{
if(Physics.Raycast(ray,out hit,100))
{
   Debug.Log("hitted object "+hit.transform.gameObject.name);   
}

}
}

am getting the error as:

NullReferenceException: UnityEngine.Camera.ScreenPointToRay (Vector3 position)

well i have used the same script in my another scene...thats worked perfectly...but now its not working well....in briefly i have attached mesh colliders all of my gameobjects.....

i have a board in my game with mesh collider attached...and lot of coins(like cylinders) in it...i want to touch that coins and wanna to get that coin name....thats it my problem...any one explain what kind of problem i have now.....

thanks.

you probably don't have a camera tagged as "MainCamera" in the scene with the error and you have a camera tagged as "MainCamera" in the scene in which the script works. Just open the scene in which the error occurs, select the camera, and select "MainCamera" in the Tag property.

You can easily test this in script by commenting out your code and adding this line to your Update():

print ("My main camera is: " + Camera.main.name);

My guess is you will get a similar error.