Door script not completely working help!

hey there. my script here is really annoying me because when ever i put it on a door and the tags and that are working but it keeps on looping only the (!stat) and i can’t get it to switch to (stat). it would be greatly appreciated if someone could help fix this script, thanks

public var stat : boolean;
public var able : boolean;
var open : AudioClip;
var clos : AudioClip;

function Awake () {

 if(stat){
 
   animation.Play("openstat");
 
 }

}

function OnTriggerEnter( other : Collider ) {

   if(other.tag == ("Player")){
   
     able = true;
   
   }

}

function OnTriggerExit( other : Collider ) {

   if(other.tag == ("Player")){
   
     able = false;
   
   }

}



function Update () {

  if(able){
  
    if(stat){
    
      if(Input.GetKeyDown("e")){
      
      stat = false;
      animation.Play("closingdoor", PlayMode.StopAll);
      audio.PlayOneShot(clos);
      Debug.LogWarning("im now closed");
      
      }
    
    }
    
     if(!stat){
    
      if(Input.GetKeyDown("e")){
      
      stat = true;
      animation.Play("openingdoor", PlayMode.StopAll);      
      audio.PlayOneShot(open);
      Debug.LogWarning("im now open");
      
      }
    
    }
    
  }

}

One issue (perhaps ‘the’ issue) is that you need an ‘else’ on line 54. Right now if the ‘e’ key is pressed, you do the ‘if (stat)’ block which sets ‘stat’ to ‘false’ which means that the 'if (!stat) block will also be executed in the same frame.