cant run my character by holding shift

i am trying to get my character to run while holding Lshift key. in my case i have separate animation for walking and running. after spending two days i manage to get it work partially. the problem is, to run first i need to hold Lshift and then press W . if i press Lshift while walking (after W key) it running with walking animation.
[SerializeField]private float MovementSpeed = 0f;
[SerializeField] float WalkingSpeed = 0f;
[SerializeField] float RunningSpeed = 0f;
[SerializeField] float mousesensitivity = 0f ;
[SerializeField] GameObject camara;
private CharacterController cc;
private float xrotation = 0f;
private bool shift = false ;
private Animator animator;
private bool IsRunning = false;
// Start is called before the first frame update
void Start()
{
cc = gameObject.GetComponent();
Cursor.lockState = CursorLockMode.Locked;
animator = gameObject.transform.GetChild(0).gameObject.GetComponent();
}

    // Update is called once per frame
    void Update()
    {
        PlayerMovement();
        PlayerRotation();
    }
    private void PlayerMovement()
    {
        float x = Input.GetAxis("Horizontal");
        float y = Input.GetAxis("Vertical");
        Vector3 movemontVector = transform.right * x + transform.forward * y;
        animator.SetFloat("X", x);
        animator.SetFloat("Y", y);
        shift = Input.GetKey(KeyCode.LeftShift);
        if (Input.GetKey(KeyCode.W) && shift == true)
        {
            IsRunning = true;
            animator.SetBool("Run", true);
            MovementSpeed = RunningSpeed;
        }
        else if (Input.GetKeyUp(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.A))
        {
            MovementSpeed = WalkingSpeed;
            IsRunning = false;
        }
        else if ( shift == false )
            {
            animator.SetBool("Run", false);
        }

        if( IsRunning == false)
        {
            if (x == 0 && y == 0)
            {
                animator.SetBool("Walk", false);
            }
            else
            {
                animator.SetBool("Walk", true);
            }

        }
        cc.Move(movemontVector * Time.deltaTime * MovementSpeed);
    }
    private void PlayerRotation()
    {
        float Mousex = Input.GetAxis("Mouse X")* mousesensitivity* Time.deltaTime;
        float Mousey = Input.GetAxis("Mouse Y") * mousesensitivity * Time.deltaTime;

        xrotation -= Mousey;
        xrotation = Mathf.Clamp(xrotation, -20f, 20f);
        camara.transform.localRotation = Quaternion.Euler(xrotation, 0, 0);
        transform.Rotate(Vector3.up * Mousex);

    }
}

you should use get keydown for your shift button, and do the check within the other statement rather than compounding it, like this:

    if (Input.GetKey(KeyCode.W)
    {
        if (Input.GetKeyDown(KeyCode.LeftShift)
        {
                 IsRunning = true;
                 animator.SetBool("Run", true);
                 animator.SetBool("Walk", false);
                 MovementSpeed = RunningSpeed;
        }
        else
        {
                 IsRunning = false;
                 animator.SetBool("Run", false);
                 animator.SetBool("Walk", true);
                 MovementSpeed = WalkingSpeed;
        }
    }