Animation does not play when using a script

I have created two animations called Idle and SpinAttack. One is just a simple Idle animation and the other is a spin attack and i want them to play depending on the state my enemy is in.

I got everything working so far but when i set it so my SpinAttack animations with this code:

case BossStates.Idle:

                if (Input.GetKey(KeyCode.G)) {

                    bossState = BossStates.SpinAttack;
                }

                         
                break;

            case BossStates.SpinAttack:
                timer = timer - Time.deltaTime * delayTime;



                anim.Play("SpinAttack",-1, 0f);


                


                break;

The SpinAttack animation instead of playing like i expected just reset the rotation of my enemy like it should do as it’s about to play but it doesn’t play and i don’t know why… It just doesn’t play but when i make the animation the default animation then it works perfectly but it’s always playing

This is my Animator:
59237-stupid-images-2.jpg

Any help?

As i see in your animator you have provided no way for your gameobject to enter the Spinattack state. From spin attack it can go back to idle and from entry to idle. But how do you want it to go to spin attack.