Play animation only when chest is closed.

So i have a chest that plays an animation(opens) when you press f. my problem is if you press f again it plays the same “open chest animaiton” even if it’s already open. What i want is to be able to play the “open chest animation” only when the chest is closed.

public var animationClip : AnimationClip;
private var open : boolean;
private var enter : boolean;

var doorOpenSound : AudioClip;
var doorShutSound : AudioClip;

function Start(){

}

//Main function
function Update (){


if(Input.GetKeyDown("f") && enter){
open = !open;
PlayForwards();

	}
}

function OnGUI(){
if(enter){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 100, 150, 30), "Press 'F' to open");
	}
}

//Activate the Main function when player is near the door
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
	}
}

//Deactivate the Main function when player is go away from door
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
enter = false;

if (open == true) {

PlayBackwards();
open = false;
		}

	}

}

function PlayForwards()
{
   animation[animationClip.name].speed = 3.0f;
   animation.Play(animationClip.name);
}
 
function PlayBackwards()
{
   animation[animationClip.name].speed = -3.0f;
   animation[animationClip.name].time = animation[animationClip.name].length;
   animation.Play(animationClip.name);
}

All you need to do is where you check if the f key is pressed add a check that the chest is not already open

if (Input.GetKeyDown("f") && enter && !open)