Hey guys, I am trying to make it that I can only sprint when I am already walking. I want to make it that sprinting and my clip will only work if I'm already moving. Thanks

public float jumpForce = 2f;

    public float moveSpeed = 6.75f;

    public CharacterController cc;

    public AudioSource GrassRun;

    Vector3 velocity;

    public float gravity = -9.81f;

    public Transform groundCheck;

    public float groundDistance = 0.4f;

    public LayerMask groundMask;

    bool isGrounded;

    public float sprintSpeed = 13f;

    PlayerMove basicMovementScript;

    bool isWalking;


   void Start()
    {
        basicMovementScript = GetComponent<PlayerMove>();
        
    }

    // Update is called once per frame
    void Update()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        //Walking

        Vector3 move = transform.right * x + transform.forward * z;

        cc.Move(move * moveSpeed * Time.deltaTime);
      

        //Gravity

        velocity.y += gravity * Time.deltaTime;
        cc.Move(velocity * Time.deltaTime);

        //Jumping
        
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpForce * -2f * gravity);
        }
        // Sprint



        if (Input.GetKeyDown(KeyCode.LeftShift) && isWalking)
        {
            Sprint();
            GrassRun.Play();
        }


        else if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            StopSprinting();
            GrassRun.Stop();
        }


        //Sprint Code



        void Sprint()
        {
            basicMovementScript.moveSpeed += sprintSpeed;
        }
        void StopSprinting()
        {
            basicMovementScript.moveSpeed -= sprintSpeed;
        }


    }
}

Try making the “isWalking” bool public, and in the basicMovement script, reference this script and when it is walking, set it to true. Else, set it to false.