animator.GetCurrentAnimatorStateInfo(0).IsName not working

So, this is probably a stupid question but i’m really not a good programmer. I am currently setting up animations for combat and the way i change states is when the script detects that you’re pressing left mouse button it looks at what weapon that is equipped and then changes the “Attack” float to 1 which means it’s gonna play the dagger animation and then it constanly looks if it’s still playing the animation.
After it concludes that the animation is over it sets the “Attack” float back to 0 and goes to Idle state.
Problem is that the GetCurrentAnimatorStateInfo isn’t working. I have been looking for solutions for over a day and I haven’t found anything.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;

public class Fight_script : MonoBehaviour
{

int CurrentWeapon;
public Animator animator;

public void WeaponType(int number)
{
    CurrentWeapon = number;
}
void Start()
{

}
void Update()
{
    if (Input.GetKeyDown(KeyCode.Mouse0))
    {
        //print("nojs");
        switch (CurrentWeapon)
        {
            case 1:
                Dagger();
                break;
            case 2:
                Sword();
                break;
            case 3:
                Hammer();
                break;

        }           
    }
}

void Dagger()
{
    animator.SetFloat("Attack", 1);
    //print("nojs2");
    bool isplaying = true;
    while (isplaying)
    {
        if (animator.GetCurrentAnimatorStateInfo(0).IsName("Dagger_Down"))
        {
            Debug.Log("Playing");
            isplaying = true;
        }
        else
        {
            Debug.Log("not Playing");
            isplaying = false;
            animator.SetFloat("Attack", 0);
        }
    }
}

void Sword()
{
    animator.SetFloat("Attack", 2);
}

void Hammer()
{
    animator.SetFloat("Attack", 3);
}
}

Nvm, it seems i’m a complete dumb dumb and the problem isn’t this.