nvm I figured it out, I used object space and simply checked if the handle was within angle limit and if so then move it
local cf = CFrame.lookAt(turretcontrols.PivotHandlePart.Position, Vector3.new(ray.Position.X, turretcontrols.PivotHandlePart.Position.Y, ray.Position.Z))
local newcf = cf:ToObjectSpace(turretcontrols.PivotHandlePart.CFrame)
local x,y,z = newcf:ToOrientation()
local finaldegree = math.deg(y)
if finaldegree < -35 and finaldegree > -125 then
handle:PivotTo(cf)
end