Animation to stop after ran once.

Basically, Its a pistol I need to play a shooting animation, For some reason the animation does not play and I also need it to play till end of animation first loop, I’m hoping you can help me with this.
Here’s what I have so far.

void Update()
{
    if (Input.GetButtonDown("Fire1"))
    {
        GetComponent<Animator>().SetBool("IsShooting", true);
    }

    if (Input.GetButtonUp("Fire1"))
    {
        GetComponent<Animator>().SetBool("IsShooting", false);
    }
}

Something like this might work, but you have to make sure that you have the Shooting Animation’s loop turned off. This is untested off the top of my head, so I hope this helps in some way! Animations are tricky sometimes, so if you still can’t figure it out after this, then just lookup a tutorial on a shooting animation for example.

public Animation shootingAnim;

void Update()
{
     if (Input.GetButtonUp("Fire1"))
     {
          GetComponent<Animator>().Play(shootingAnim);
     }
}