Crosshair when you look at a door

I created a script that shows a particular crosshair when the player looks at a openable door. But there is a problem: in my scene there are two doors with the same script, but only if the player looks one of these doors then the crosshair will be enabled.

I put only the void with this function:

void Update () 
	{
		RaycastHit hit;
		ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

		Crosshair_Changes scriptCam = Camera.main.GetComponent<Crosshair_Changes> ();

		if (interaction == true && Physics.Raycast (ray, out hit) && animationStop == true && hit.transform.name == name) 
		{
			scriptCam.ViewOpenableDoor ();

			if (locked == false) 
			{
				if (Input.GetKeyDown ("e")) 
				{
					changeDoorState ();
				}
			} 
			else if (locked == true && isBreaking == false) 
			{
				if (Input.GetKeyDown ("e")) 
				{
					
				}
			} 
			else if (locked == true && isBreaking == true) 
			{
				if (Input.GetKeyDown ("e")) 
				{
					Breaking_Rotating_Handle breakScript = handle.GetComponent<Breaking_Rotating_Handle> ();
					breakScript.breakHandle ();
				}
			}
		} 
		else 
		{
			scriptCam.StopViewOpenableDoor ();
		}
	}

This script is attached to the doors, instead the void OnGUI () is located in another script attached to the camera.
I don’t undestand what is the problem.

just give some tag to the door u want to enable crosshair… and then on the condition of raycast, change code to following:

if (interaction == true && Physics.Raycast (ray, out hit) && animationStop == true && hit.transform.name == name)

change following:

hit.transform.name==name to hit.transform.CompareTag(“requiredDoor”)

I solved it… i put a boolean value to call the function scriptCam.StopViewOpenableDoor ()

void Update () 
	{
		RaycastHit hit;
		ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

		Crosshair_Changes scriptCam = Camera.main.GetComponent<Crosshair_Changes> ();

		if (interaction == true && Physics.Raycast (ray, out hit) && animationStop == true && hit.transform.name == name) 
		{
			scriptCam.ViewOpenableDoor ();
			crosshairStop = true;

			if (locked == false) 
			{
				if (Input.GetKeyDown ("e")) 
				{
					changeDoorState ();
				}
			}  
			else if (locked == true && isBreaking == true) 
			{
				if (Input.GetKeyDown ("e")) 
				{
					Door_isBreaking breakScript = GetComponent<Door_isBreaking> ();
					breakScript.Breaking ();
				}
			}
		} 
		else
		{
			if (crosshairStop == true) 
			{
				scriptCam.StopViewOpenableDoor ();
				crosshairStop = false;
			}
		}
	}