Door Opening And Closing

Hello, I have been trying to solve this problem i’ve had with opening and closing doors. It works perfectly besides after you open then close it, once you hit “F” to open again it doesn’t work.

The script is down below

var DoorStatus : boolean = true;

function OnTriggerStay (myTrigger : Collider) { 
 if(myTrigger.gameObject.name == "First Person Controller" ){   
   if(Input.GetKeyDown ("f"))  
     if(DoorStatus){
     animation.Play();
       animation.wrapMode = WrapMode.ClampForever;
        DoorStatus = false;
                
   } 
   }
 if(myTrigger.gameObject.name == "First Person Controller"){
  if(Input.GetKeyDown ("g"))
   if(!DoorStatus)
     animation.Play("Door Animation Close");
         animation.wrapMode = WrapMode.ClampForever;
          
           
  }   
}

You need to set DoorStatus back to true. Put on line 18:

DoorStatus = true;

like robertbu stated, you need to make DoorStatus = true again. I think you also need brackets enclosing the DoorStatus statement so that it doesn’t go true every time you hit g, only when it closes. Also I guess the if statement for input on “G” would require one too, but maybe not if it worked for your “F” key.

 if(myTrigger.gameObject.name == "First Person Controller"){
    if(Input.GetKeyDown ("g")){
       if(!DoorStatus){
            animation.Play("Door Animation Close");
            animation.wrapMode = WrapMode.ClampForever;
            DoorStatus = true;
       }
    }
 }