how to detect a mouse click that happened but wasnt on the gameobject?

Is there a way to detect a mouse click input and do something but only if the click was somewhere other than the gameobject? so its checking if the mouse was clicked but the gameobject was clicked? then do something. For example shoot if mouse is clicked anywhere but dont shoot if mouse is clicked on gameobject.

using UnityEngine;
using System.Collections;

public class Tester : MonoBehaviour {
public bool shotEnabled;

void Update () {

	RaycastHit hit;
	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	if (Physics.Raycast (ray, out hit, 100f)) {
		if (Input.GetMouseButtonDown (0)) {
			if (hit.transform.name == "Cube") {
				shotEnabled = false;
			} else {
				shotEnabled = true;
			}
		}
	}
}

}

This should do as you want. It works on a simple cube object with collider. You’ll want to change the two Debug.Log lines to a function you want to call in the instances where it is hit or missed:

public class MissScript : MonoBehaviour {

void Update () {
	if (Input.GetMouseButtonDown(0))
	{
	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	RaycastHit hit;
	
	if (Physics.Raycast(ray, out hit) && this.gameObject.Equals(hit.transform.gameObject)) Debug.Log ("Hit");
	else Debug.Log ("Miss");
	}
}

}