Why does my climb stairs animation not play?

I’m trying to make an animation play, when the player is in a trigger(collider) and presses ‘Z’. The ladder-climb animation is on the Player and the following script is on the trigger:
If some-one can help me, thanks.

#pragma strict

var Player : GameObject;
var IsInTrigger : boolean = false;

function Start () {
	guiText.enabled = false;
	Player = GameObject.FindWithTag("Player");
	}

function OnTriggerEnter(other: Collider){
	if (other.tag == "Player"){ // remember to tag the player as "Player"
	guiText.enabled = true;
	IsInTrigger = true;
	}
}

function OnTriggerExit(other: Collider){
	if(other.tag == "Player"){ 
	guiText.enabled = false;
	IsInTrigger = false;
	}
}
	
if(IsInTrigger == true && Input.GetKeyUp(KeyCode.Z)){
	Player.animation.Play("ClimbLadder");
	IsInTrigger = false;
	guiText.enabled = false;
	}

I think you should put the whole if(IsInTrigger…) statement within the Update function or it won’t be checked every frame.