How would I fix this script so the animation plays on get key hold? Any help is much appreciated

function Update(){
if(Input.GetKeyDown(“w”)){
animation.Play(“animation”);
}

 if(Input.GetKeyDown("a")){
     animation.Play("animation");
 }

 if(Input.GetKeyDown("s")){
     animation.Play("animation");
 }

 if(Input.GetKeyDown("d")){
     animation.Play("animation");
 }

}

You may need to make a co-routine in coordination with this to get the delay you want, but use GetKey(). If you read it’s description, it says that it works like a rapid fire, but you could set it up with WaitForSeconds and Animation.Stop to get at least a mimic of what you want. Unless you mean to have the Animation play and stop for as long as you hold it, in that case I’m actually trying to figure that out myself.

You might want to try Input.GetKey instead of Input.GetKeyDown.