Play Animation on keypress?

I want to play an animation on keypress any idea how I tried this but it didnt work I had all the components in the correct place.

Script (part of it)

function Update () {
if(Input.GetMouseButtonDown(1))
AnimationClip.play("recoil")
}

Please correct that script thanks!

write
if(Input.GetMouseButtonDown(1)){
GameObject.Find(“name of the object which has the animation”).animation.Play(“recoil”);
}

Sorry, I had just stumbled upon this post whilst searching for something else. But this is a syntax error. You’re missing an open and close bracket for the if statement. You also needed to have the semicolon ; at the end of the animation line.