if boolean == true ...else...

Help with Syntax please!!

Boolean is triggered once but never makes it to else or next part to be false:

#pragma strict

var animator : Animator;
var myBool : boolean;
 
function Start () {
    animator = GetComponent(Animator);
}
 

function OnMouseUp () {

if (myBool == false) {
animator.SetBool("myBool", true);
}
else {
//if (myBool == true){
animator.SetBool("myBool", false);
}

}

@say_forever , @NewBeeLiu

Yes that’s it:

#pragma strict

var animator : Animator;
 var myBool : boolean;
 
function Start () {
    animator = GetComponent("Animator");
}


function OnMouseUp () {
Debug.Log("MO");


       if (myBool == false) {
      animator.SetBool("myBool", true);
      Debug.Log("SetBool");
      }
      else {
      //if (myBool == true){
      animator.SetBool("myBool", false);
      Debug.Log("SetBoolFalse");
      }
      
     myBool = !myBool;  // add this line
     
      }

because you do not change the value of myBool.

     function OnMouseUp () {
     
     if (myBool == false) {
     animator.SetBool("myBool", true);
     }
     else {
     //if (myBool == true){
     animator.SetBool("myBool", false);
     }
     
    myBool = !myBool;  // add this line
     }