How to animate a 2D character and stop it when it stops moving?

I have a simple code that moves my player but I cannot get it to animate properly. I have set up a parameter called speed and if speed is greater than 0.01 then it will animate walking. However I cannot integrate this into my code. Please help. Thanks in advance!
My code:

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

public class Player_Move : MonoBehaviour
{
    private bool facingLeft = true;
    private Rigidbody2D rb;
    private Animator anim;
    public float speed;
    private float hold = 0f;
    private float velocity;

    void Start()
    {
        targetPosition = new Vector2(0.0f, 0.0f);
        rb = GetComponent<Rigidbody2D>();
        anim = GetComponent<Animator>();
    }

    Vector3 targetPosition;
    Vector3 theScale = new Vector3(1f, 1f, 1f);

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            targetPosition = Input.mousePosition;
            targetPosition = Camera.main.ScreenToWorldPoint(new Vector3(targetPosition.x, targetPosition.y, 0.0f));

            //moving to he right
            if (targetPosition.x - this.transform.position.x > 0)
            {
                theScale.x = 1;
                rb.transform.localScale = theScale;
                hold = 1f;
            }
            //moving to the left
            if (targetPosition.x - this.transform.position.x < 0)
            {
                theScale.x = -1;
                rb.transform.localScale = theScale;
                hold = 1f;
            }
        }
        if (targetPosition.x - this.transform.position.x == 0)
        {
            hold = 0f;
        }

        anim.SetFloat("Speed", Mathf.Abs(hold));
        this.transform.position = Vector2.MoveTowards(this.transform.position, targetPosition, speed * Time.deltaTime);
    }

    void reverseImage()
    {
        facingLeft = !facingLeft;
        Vector2 theScale = rb.transform.localScale;
        theScale.x *= -1;
        rb.transform.localScale = theScale;
    }

}

Best way to debug this is select the animator, then doubleclick on the controller to bring up the Animator window. Now keep that animator selected and run the game, and watch what states are happening in the controller. The controller will show you what states it goes to when you set those floats, so you can reason about if the controller transitions are set up properly.

You can also liberally sprinkle in Debug.Log() calls to find out if any of the above code is even running, which is also a great thing to know going into the problem.

I know the code is running, it is just not functioning as I intended.

+1000000000000000

+3333333333333333

+please i beg

+helpppppppppp meeeeeeeeeeee

You should follow Kurt-Dekker’s advice. Place some Debug.Logs in just about every curly bracket and make sure that every line is running properly. You said you know the code is running but as long as there are no compiling errors, it will run. The question is, is every single line in my code running as intended? By debugging like Kurt suggested you can find out why. You should Debug.Log(hold) to see if that value is actually changing or not. Also, look at that float parameter from the Animator window, is it changing as well?

Also, per the forum rules, you need to post what you have tried, what you expect to happen and what exactly is happening. Also, don’t beg for code…