Interact Icon is acting strange

Hello all, Hopefully this is the last time i need to be on here annoying people but i’ve hit upon one last snag. I had an icon for interactable objects that would show up when you hovered over them to let the player know that they could press on it.

using System.Collections;
using UnityEngine.UI;

public class Interact : MonoBehaviour
{
public string interactButton;

public float interactDistance = 3f; 
public LayerMask interactLayer; 

public Image interactIcon; 

public bool isInteracting;

void Start ()
{
	if(interactIcon != null)
	{
		interactIcon.enabled = false;
	}
}

void Update ()
{
	Ray ray = new Ray (transform.position, transform.forward);
	RaycastHit hit;

	if (Physics.Raycast (ray, out hit, interactDistance, interactLayer)) {
		if (isInteracting == false) {
			if (interactIcon != null) {
				interactIcon.enabled = true;
			}

			if (Input.GetButtonDown (interactButton)) {
				if (hit.collider.CompareTag ("Door")) {
					hit.collider.GetComponent<new_door> ().ChangeDoorState();
				} else if (hit.collider.CompareTag ("Key")) {
					hit.collider.GetComponent<New_key> ().Unlocknew_door ();
				} if (hit.collider.CompareTag ("Fusebox")) {
					hit.collider.GetComponent<Fusebox> ().FadeOut ();
			}
		} 	

	 else {
		interactIcon.enabled = false;
	}
} 

}
}
}

It was this line that was added in at the end so i could interact with another object, before its inclusion the script worked perfectly. Now the icon only shows up when you press the interact button and i can’t for the life of me figure out why that is. If anyone could clarify this it would be greatly appreciated. and @Maniva This is honestly the last time I will bother you… at least for this game :L

@OptimisticSoundGuy

As I mentioned in a previous question you should rethink moving this out of the Update() function because it is called every frame. But if you leave everything the way it is try this

void OnMouseOver()
{
    if ((!isInteracting) && (!Input.GetButtonDown (interactButton))
    {
        interactIcon.enabled = true;
    }
}

A better way to go though is to remove everything from the Update() function and do this

public Camera camera;

void OnMouseOver()
{
    if ((!isInteracting) && (!Input.GetButtonDown (interactButton))
    {
        interactIcon.enabled = true;
    }
    else if ((camera) && (Input.GetButtonDown(interactButton)))
    {
        Vector3 mousePos = camera.ScreenToWorldPoint(Input.mousePosition);
        if (Physics.Raycast(ray, hit))
        {
            if (hit.collider.CompareTag ("Door"))
            {
                hit.collider.GetComponent ().ChangeDoorState();
            }
            else if (hit.collider.CompareTag ("Key"))
            {
                hit.collider.GetComponent ().Unlocknew_door ();
            }
            else if (hit.collider.CompareTag ("Fusebox"))
            {
                hit.collider.GetComponent<Fusebox> ().FadeOut ();
            }
        }
    }
}

Im an idiot never mind, its working now with more fiddeling. Thank you for all your help, this game would not have been possible without you. If you every need any sound work done for you or any help in that category dont hesitate too ask man, it would be the least I could do after all you’v done for me !!