Rotation issues

I have some code that will change the position and rotation of my RPM avatar. Unfortunately, it sometimes ends up in a loop where the player will keep rotating clockwise around the y-axis.

Do you have any idea why this might be happening?

Hello,
Where are you calling this part of the code?