animation condition won't activate on movement

here’s a simple movement script supposed to activate the condition for an animation to play out. when I move the character to the right , the animation works just fine. but when I press “a” / “left arrow”, the character does turn left but it keeps sliding instead of doing the running animation. the condition for the running animation to be activated is if the speed is greater than 0 and the condition to transition back is if the speed is less than 0.01. here’s my code:

using UnityEngine;

public class Movement2D : MonoBehaviour
{
    public float movementspeed = 5;
    public float jumpforce = 12f;
    public bool isGrounded = false;
    public Animator animator;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Jump();
        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
        

        transform.Translate(Input.GetAxis("Horizontal") * movementspeed * Time.deltaTime, 0, 0);

        Vector3 characterScale = transform.localScale;

        if (Input.GetAxis("Horizontal") < 0)
        {
            characterScale.x = -0.3577406f;
            //transform.position += movement * Time.deltaTime * movementspeed;
            animator.SetFloat("Speed", movementspeed);
        }

        if (Input.GetAxis("Horizontal") > 0)
        {
            characterScale.x = 0.3577406f;
            //transform.position += movement * Time.deltaTime * movementspeed;
            animator.SetFloat("Speed", movementspeed);
        }
        else
        {
            animator.SetFloat("Speed", 0);
        }
        transform.localScale = characterScale;

    }

    void Jump()
    {
        if (Input.GetButtonDown("Jump") && isGrounded == true)
        {
            gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpforce), ForceMode2D.Impulse);
        }

    }
}

Try Input.GetAxisRaw instead and see if it works.

You can also play the animation instead of using parameters.
animator.Play(“clipName”);
try Checking on Root Animation on the inspector as well.