Crouch enabled on certain areas! problem

hi i want to add certain colliders with trigger that force the player to crouch. The player has characterMotor.js which came with unity by default. To make the player crouch and run i add a script named RunAndCrouch.js i add some code to force the player to crouch in certain areas by collide with trigger. but it does not seem to work, plz tell me if there is anything i am doing wrong!!

here is the RunAndCrouch.js

var walkSpeed: float = 7; // regular speed
var crchSpeed: float = 3; // crouching speed
var runSpeed: float = 20; // run speed

private var chMotor: CharacterMotor;
private var ch: CharacterController;
private var tr: Transform;
private var height: float; // initial height
private var isCrouching : boolean = false;
private var isInCrouchArea : boolean = false; 

function Start(){
    chMotor = GetComponent(CharacterMotor);
    tr = transform;
    ch = GetComponent(CharacterController);
	height = ch.height;
}
 
function Update(){
 
    var h = height;
    var speed = walkSpeed;
    
    if (ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift")){
        speed = runSpeed;
    }
   //Either pressing C or currently in crouch area will make us crouch
   isCrouching = Input.GetKey("c") || isInCrouchArea; 
 
   if(isCrouching) {
         h = 0.5 * height;
        speed = crchSpeed; // slow down when crouching
   }
    chMotor.movement.maxForwardSpeed = speed; // set max speed
    var lastHeight = ch.height; // crouch/stand up smoothly 
    ch.height = Mathf.Lerp(ch.height, h, 5*Time.deltaTime);
    tr.position.y += (ch.height-lastHeight)/2; // fix vertical position
}


function OnTriggerEnter( other : Collider ) {
   if( other.gameObject.tag == "crouchArea" && isCrouching ) {
      isInCrouchArea = true;
   }
}
 
function OnTriggerExit( other : Collider ) {
   if( other.gameObject.tag == "crouchArea" ) {
      isInCrouchArea = false;
   }
}

and i also add those gameobject tags to the collider, but nothing work!

The problem I found was once isCrouched was set to true, there was no set way of returning it to false;

#pragma strict

var walkSpeed : float = 7; // regular speed
var crchSpeed : float = 3; // crouching speed
var runSpeed : float = 20; // run speed

private var chMotor : CharacterMotor;
private var ch : CharacterController;
private var tr : Transform;
private var height : float; // initial height

private var isCrouching : boolean = false;
private var isInCrouchArea : boolean = false; 

function Start()
{
	chMotor = GetComponent( CharacterMotor );
	tr = transform;
	ch = GetComponent( CharacterController );
	height = ch.height;
}

function Update()
{
	var h = height;
	var speed = walkSpeed;
	
	if ( ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") )
	{
		speed = runSpeed;
	}
	
	//Either pressing C or currently in crouch area will make us crouch
	//isCrouching = Input.GetKey("c") || isInCrouchArea;
	
	isCrouching = false; // make sure is crouching is false unless found true as below
	
	if ( Input.GetKey("c") || isInCrouchArea || Input.GetKey("left ctrl") )
	{
		isCrouching = true;
	}
	
	//
	if ( isCrouching ) 
	{
		h = 0.5 * height;
		speed = crchSpeed; // slow down when crouching
	}
	
	//
	chMotor.movement.maxForwardSpeed = speed; // set max speed
	var lastHeight = ch.height; // crouch/stand up smoothly
	ch.height = Mathf.Lerp( ch.height, h, 5.0 * Time.deltaTime );
	tr.position.y += ( ch.height - lastHeight ) * 0.5; // fix vertical position
}


//function OnTriggerEnter( other : Collider ) 
function OnTriggerStay( other : Collider )
{
	if ( other.gameObject.tag == "crouchArea" && isCrouching ) 
	{
		isInCrouchArea = true;
	}
}

function OnTriggerExit( other : Collider ) 
{
	if ( other.gameObject.tag == "crouchArea" ) 
	{
		isInCrouchArea = false;
	}
}

=============================================================

Edit :

Have included a timer, for when first entering the trigger zone, the character controller cannot move until the animation is played. You can determine however long you want the wait time to be calculated, I have simply exposed a float in seconds. With this example, you’ll note for 1.2 seconds after entering the trigger, the controller cannot move.

#pragma strict

var walkSpeed : float = 7; // regular speed
var walkBackwardsSpeed : float = 7;
var walkSidewaysSpeed : float = 7;

var crchSpeed : float = 3; // crouching speed
var crchBackwardsSpeed : float = 3;
var crchSidewaysSpeed : float = 3;

var runSpeed : float = 20; // run speed
var runBackwardsSpeed : float = 12;
var runSidewaysSpeed : float = 16;

public var animationTime : float = 1.2; // length of animation in seconds

private var animTimer : float = 0.0; // timer to freeze CharacterControllerCharacterController

private var chMotor : CharacterMotor;
private var ch : CharacterController;
private var tr : Transform;
private var height : float; // initial height

private var isCrouching : boolean = false;
private var isInCrouchArea : boolean = false; 
private var isRestrictedMovement : boolean = false; 

function Start()
{
	chMotor = GetComponent( CharacterMotor );
	tr = transform;
	ch = GetComponent( CharacterController );
	height = ch.height;
}

function Update()
{
	var h : float = height;
	var speed : float = walkSpeed;
	var backwardsSpeed : float = walkBackwardsSpeed;
	var sidewaysSpeed : float = walkSidewaysSpeed;
	
	if ( ch.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") )
	{
		speed = runSpeed;
		backwardsSpeed = runBackwardsSpeed;
		sidewaysSpeed = runSidewaysSpeed;
	}
	
	//Either pressing C or currently in crouch area will make us crouch
	//isCrouching = Input.GetKey("c") || isInCrouchArea;
	
	isCrouching = false;
	
	if ( Input.GetKey("c") || isInCrouchArea || Input.GetKey("left ctrl") )
	{
		isCrouching = true;
	}
	
	//
	if ( isCrouching ) 
	{
		h = 0.5 * height;
		speed = crchSpeed; // slow down when crouching
		backwardsSpeed = crchBackwardsSpeed;
		sidewaysSpeed = crchSidewaysSpeed;
	}
	
	// check if animation is playing
	if ( isRestrictedMovement )
	{
		speed = 0.0;
		backwardsSpeed = 0.0;
		sidewaysSpeed = 0.0;
		
		// maintain timer
		animTimer += Time.deltaTime;
		
		if ( animTimer > animationTime )
		{
			isRestrictedMovement = false;
		}
	}
	
	chMotor.movement.maxForwardSpeed = speed;
	chMotor.movement.maxBackwardsSpeed = backwardsSpeed;
	chMotor.movement.maxSidewaysSpeed = sidewaysSpeed;
	
	// scale CharacterController Y
	var lastHeight = ch.height; // crouch/stand up smoothly
	ch.height = Mathf.Lerp( ch.height, h, 5.0 * Time.deltaTime );
	tr.position.y += ( ch.height - lastHeight ) * 0.5; // fix vertical position
}

function PlaySomeAnimation()
{
	//animationTime = 1.2;
	animTimer = 0.0;
	isRestrictedMovement = true;
}

//function OnTriggerEnter( other : Collider ) 
function OnTriggerStay( other : Collider )
{
	if ( other.gameObject.tag == "crouchArea" && isCrouching ) 
	{
		// check if the trigger has just been crouched in fo rthe first time
		if ( !isInCrouchArea )
		{
			PlaySomeAnimation();
		}
		
		isInCrouchArea = true;
	}
}

function OnTriggerExit( other : Collider ) 
{
	if ( other.gameObject.tag == "crouchArea" ) 
	{
		isInCrouchArea = false;
	}
}

=============================================================