MouseClick and gameObject

Hi,
I want to retrieve the name of this gameObject on my scene when I click on an object in order to execute an animation but I can not do it. My click return nothing.

Code :

// Builds a ray from camera point of view to the mouse position

	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	RaycastHit hit;
	// Casts the ray and get the first game object hit
	if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
		return hit.transform.gameObject;
	else
		return null;

Do you have an idea of the problem ? I attach this script on my gameObject (a Door)

Thanks

I simplified my code :

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

RaycastHit hit;

// Casts the ray and get the first game object hit

	if (Physics.Raycast(ray, out hit))
	{
		Debug.Log("This hit at " + hit.point );
		return hit.transform.gameObject;
	}
	else
	{
		Debug.Log("null");
		return null;		
	}

But nothing. The variable ‘ray’ is correctly implemented. I noticed that the variable returned a lightMapCoord NullException