Camera like Running with Rifles

Hello everyone. I want to make a camera like in the game “Running with rifles”, in other words I want the camera to follow the mouse cursor.
I used the script from this thread:
[Camera between player and mouse - Cinematics & Media - Epic Developer Community Forums][1],
but the camera moves weird when Y-coordinate is changed. You can see that on GIF. What should I do to fix this?

314369-ezgif-2-418f0c9c2f36.gif