Why isn't Unity adding the velocity?

When I run this code and press “z”, the player only moves up. On the rare occasion of spamming “z” the player might move decimal places on the x-axis. When I comment out "myRigidBody.velocity = playerVelocity; " then it seems to work but I can’t move then lol. What is the conflict?

    {
        
        float control = Input.GetAxis("Horizontal");
        Vector2 playerVelocity = new Vector2(control * speed, myRigidBody.velocity.y);
        myRigidBody.velocity = playerVelocity;
        
        Vector2 clampedPosition = transform.position;
        clampedPosition.x = Mathf.Clamp(clampedPosition.x, minX, maxX);
        transform.position = clampedPosition;
        
        if(Input.GetKeyDown(KeyCode.Z))
            {
            float xBounce = 5f;
            
            myRigidBody.AddForce(new Vector2(xBounce, 5), ForceMode2D.Impulse);
            }

        if(Input.GetButtonDown("Jump"))
        {
            Vector2 jumpVelocityToAdd = new Vector2 (0, jumpSpeed);
            myRigidBody.velocity += jumpVelocityToAdd;
        }
        
    }

Hi, it’s because you didn’t add velocity to the current velocity when u use addforce it immediately set the vel to the previous velocity myRigidBody.velocity = playerVelocity; with this function. the thing you can do is add it instead of assign it. like myRigidBody.velocity += playerVelocity;
hope that helps