The animation state ShootPistol could not be played because it couldn't be found!

Error:

The animation state ShootPistol could not be played because it couldn’t be found!
Please attach an animation clip with the name ‘ShootPistol’ or call this function only for existing animations.
UnityEngine.Animation:CrossFade(String, Single)
GunAnimations:Update() (at Assets/Scripts/GunAnimations.js:6)

Script:

function Update () {
    if(Input.GetMouseButtonDown(0))
    {
        animation.CrossFade("ShootPistol", 0.1);
    }
}

SOmeone please help Idk wtf to do

Hello sir,

Isn’t the name and description of the error pretty obvious ? It is so I’m guessing that maybe you’re confused because you have that animation on your Mecanim Avatar.

The animation object and the method you’re trying to use are for legacy animations.

Does your gameObject have an “Animation” component ? (not to be confused with “Animator”)
Does that Animation component has the animation referenced in it ? (in the “Animations” array in the inspector)