raycast

Hello
I wrote this code:

void Update () 
	{
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		Debug.DrawRay(ray.origin,ray.direction*10,Color.blue);
		RaycastHit hit;
		
		if(Physics.Raycast(ray,out hit)==true)
		{
			Debug.Log("I am here!!!");
		}

and I dont know where the problem is
the console writes me all the time:
NullReferenceException
what I need to fix?
thx for the help

Looks fine. What is the line the error occurs? Perhaps you dont have a camera tagged as MainCamera?

now i tagged the camera and its working
thx for the help