Turret rotation not doing what its supposed to do

Im currently reworking my turret controlls and im trying to make it like in War Thunder so i searched and tried some scirpts i found, example. But my turret doesnt rotate in the correct position.
Video of the turret