Trigger an animation using Javascript

Alright, I’m sure this community gets this alot, but I can’t figure it out. I’m new to Unity, and am having some trouble with animations. The only way i could figure out how to play it in game mode was to use an animation controller, but I don’t want the animaiton to play immediatly, and want to write a script so it opens when I press the ‘e’ key. This is what I’ve got, but I keep getting errors:

if (Input.GetKeyDown(“e”))

     {
         animation.Play("Door Open");
     }

}

In addition, Unity keeps moving what I’m trying to use for my trigger to open the door.

try this:

function Update()
{
if (Input.GetKey("e"))
     {
          animation.CrossFade("Door Open");
     }
}

also do you have your animation set on play automatically?
double check your setup if this doesn’t work

I don’t know why, but now it works. Thanks.