slash sword

I’m making a first person rpg but i want to know how to slash my sword

i tought i could use a script to play my “slash sword” animation but hen i press the button
it doesn’t do anything

this is my script

#pragma strict

function Update ()
{
if ( Input.GetKeyDown(“Fire1”) ) {
animation.Play(“slash sword”);
}
}

To clarify a bit on what Dann said, try something like this:

#pragma strict

public var swordSlash : AnimationClip;

function Update () {
    if (Input.GetButtonDown("Fire1")) {
        animation.Play(swordSlash);
    }
}

Then you can just select an animation clip in the inspector and you’re good to go.

One thing, though; I think you meant GetButtonDown instead of GetKeyDown. Are you declaring Fire1 as a button in the Input Manager?

You’ve listed your animation as a variable? I don’t recommend using (“…”) Instead, just call it a name like: SlashSwordAnim