I make game system like FEZ rotation but i messed up a little bit

I’m trying (or attempting) to create a game with the Paperzd plugin, and I’ve implemented the rotating mechanic of the world from FEZ. However, things got a bit complicated. I initially tried to rotate it by taking the current angle and adding 90 degrees, but it resulted in a bug every time. I couldn’t fix it, so I did it this way instead. I’m not sure if it’s useful for your purposes, but it works.

By the way, if there is a simpler way or if you can help me with editing this part, I would appreciate it.