How to activate/deactivate a gameObject by holding down the left mouse button?

So here is the script that I tried:

void Update () {
         if (Input.GetButtonDown ("Fire2") ) {
                  gameObject.SetActive(false); 
          } else {
                   gameObject.SetActive(true); 
       }
 }

Assuming that you want to have it unselected only when you have the right mouse down then you want:

void Update () {
  if (Input.GetAxis ("Fire2")==1) {
      gameObject.SetActive(false);
   } else {
      gameObject.SetActive(true); 
   }
  }

It looks like that’s what your trying to do… Hope it helps you!