Rotation problems

I am making a fps gravity shifting game.

When the player wants to change gravity i rotate the player model 90 degrees and it looks good unless I’m changing from the x axis to the z axis. Because if i do it from the y to the z it only changes 90 degrees (0,0,0) to (0,0,90/-90). But i I do it form the x axis to the z it makes the animation weird and makes the player look to the wall because it changes in 2 axes (90,0,0) to (0,0,90)

Here is my code:

// paste your code here

Here are screenshots showing what happens:

// add images here

Anybody got an idea how to solve it?