Animation reverse

Hey there!. Im having problem with my script. what the script does is that it displays a icon when you are aiming on the " door " and that works just fine and opening also. the thing Im trying to add to the script that gives me problem is animation reverse for closing the door. it gives me a error at line 41 saying that " = " is incorrect. isnt that how it suppose to be ?

function Update()
{
       var hit : RaycastHit;
 
       //check if we're colliding
       if(Physics.Raycast(transform.position, transform.forward, hit, rayCastLength))
       { 
          showSymbol = true;
 
          //with a door
          if(hit.collider.gameObject.tag == "doorl")
          {
           
              if(Input.GetKeyDown("e"))
              {
                 //open the door!
                 hit.collider.gameObject.animation.Play("doorleft");
                
               }
                }
                else
                {

                   {   
                 hit.collider.gameObject.animation.Play("doorleft").speed=-1f;
                 }
                }
                 
              
                          
 
 
          //Copy and paste the code above and rename the door animation and that's it! You now have another door in your game!
 
       }
       else
       {
         showSymbol = false;
       }
     }
   }
  }
 }

Hi the problem is very simple all you have to do is change from

CHANGE FROM

{
hit.collider.gameObject.animation.Play("doorleft").speed=-1f;
}

the reason this line doesnt work is because animation.Play(); is call only function

CHANGE TO

    {
hit.collider.gameObject.animation["doorleft"].time = hit.collider.gameObject.animation["doorleft"].length;
    hit.collider.gameObject.animation["doorleft"].speed = -1;///This lets you change speed of the animation
    hit.collider.gameObject.animation.Play("doorleft");
    }

Your Script Rewritten

var dooropen:boolean = false;
function Update(){
var hit:RaycastHit;

if(Physics.Raycast(transform.position, transform.forward,hit, rayCastLength)){

 showSymbol = true;

if(hit.collider.gameObject.tag == "doorl"){

if(Input.GetKeyDown(KeyCode.E)){
dooropen = true;
 hit.collider.gameObject.animation.Play("doorleft");
     
    }else{
if(dooropen){
         hit.collider.gameObject.animation["doorleft"].time = hit.collider.gameObject.animation["doorleft"].length;
        hit.collider.gameObject.animation["doorleft"].speed = -1;///This lets you change speed of the animation
        hit.collider.gameObject.animation.Play("doorleft");   
dooropen = false;
    }

 
     }

   }else{
 showSymbol = false;
  }
 }
}