How to make bool parameter true when moving?

I’m trying to make a script to control my animations. I made a transition with a bool parameter to go from walking animation to idle animation. I want the bool to be true when the player is moving so that the player doesn’t idle and false when the player isn’t moving so that the player does idle. For some reason, when I move my character backwards, the bool is true and the walking animation plays fine. But when I move my character forward, the bool does not become true and the animations get stuck in this back and forth between walking an idle. I’m really confused because there doesn’t seem to be anything wrong. BTW, I’m extremely new to coding and unity.

Here is the script

public class Animations : MonoBehaviour
{
private Animator anim;
private float vert;
// Start is called before the first frame update
void Start()
{
anim = GetComponent();
}

// Update is called once per frame
 
void Update()
{

    if (anim.GetFloat("Walk") == 1)
    {
        anim.SetBool("Idle", true);
    }
    else
    {
        anim.SetBool("Idle", false);
    }

    if (anim.GetFloat("Walk") == -1)
    {
        anim.SetBool("Idle", true);
    }
    else
    {
        anim.SetBool("Idle", false);
    }

    vert = Input.GetAxisRaw("Vertical");
    anim.SetFloat("Walk", vert);
   
}

}

I think,you should check animator transitions in unity

I can see you are overriding anim to nothing. Change that line on Start to

anim = GetComponent<Animator>();

Im considering both this script and the animator are in the same game object