Animation Error Help?

I have an animation that I want to play on a sword in my game but I keep getting these two errors:

The AnimationClip ‘sword’ used by the Animation component ‘Sword’ must be marked as Legacy.

Default clip could not be found in attached animations list.

also this is my Javascript code:

#pragma strict

function Update () {

if (Input.GetButtonDown("Fire1"))
    animation.Play("sword") ;

}

you are using the old animation system of unity so in import settings of your animation you should
set it as legacy animation , and you should add an animation component to your game object and add your animation to the animation array