Change relative rotation of bone transform

Not quite sure how to make this as clear as possible but i’ll try my best.

i’ve got a player that can have one of his bones rotated using transform (modify) bone function
I send this 2 values to make the rotation: the pitch and the yaw.

The yaw is calculated by taking the control rotation ( rotation of the camera )
and taking away the player rotation
so that essentially the yaw will be zero whenever the camera is facing in the direction that the player is facing.
this makes it so the yaw rotation is relative to the player

But the pitch will always rotate based on a fixed axis, from north to south.
for example, If the player faces west he will ‘lean’ to the right when i press the forward button.

any help would be appreciated

Thanks