How to block X and Z turret rotation

I have been trying to get the turret to only rotate in the Y axis and look towards the target but while keeping it base oriented with the plane under it. With my current code even though it rotates towards the target it always auto corrects it orientation to be “upright”

Any ideas on how to fix it ?

// share your code here

I made a universal turret component to handle cases like this. Here is the source code:

https://gist.github.com/andrew-raphael-lukasik/39977c56509eb60a8d44bd94e77cce7a

If you need to make it stay upright just set Gimbal Min&Max for x axis to 0: