Animation script problems

Hi all, here’s my problem. I’ve added an attack animation to my script but the thing is that now only that animation will play. It plays constantly, not when I hit the left mouse button like I want it to. Here is my script.

function Update() {

var walk = Input.GetKey( "w" );


if( walk ) {
    animation.Play( "Walk" );
}

if( Input.GetButtonDown ) {
   animation.Play( "Attack" );
}

else animation.Play( "Idle" );

}

This is becues you are using

if( Input.GetButtonDown ) {

This will trigger any time any button is pressed.

So even if you press ‘w’ it will still trigger the attack animation.

You need to assign a key just like you did for the walk animation.