Get the pitch angle to a point based on LookVector

I’m trying to find the angle between a point and the direction that the gun is facing. I’ve been able to get the angle from the initial angle to the target point, or from either the X or Y axis based on some weird vector math I most likely messed up. I haven’t been able to figure out how to find the angle based on the current direction of the gun.

Here’s a rough drawing of what I want to accomplish:


It actually aims from the green attachment point at the start of the gun, rather than from the end.

You want to get the angle you showed in the picture?

Yes, I want to get the angle between the blue line (look vector) and red line (line to target)

I believe you can do something like this

local Difference = (Position2 - Position1).Unit

local Look = Part1.CFrame.LookVector

local Dot = Look:Dot(Difference)

local Angle = math.deg(math.acos(Dot / (Difference.Magnitude * Look.Magnitude)))
print(Angle)

Although, you can just use CFrame.lookAt to aim the turret

Turrent.CFrame = CFrame.lookAt(Turrent.Position, Target.Position)

Also, the code that gives the angle is pretty useless because you won’t know the axis/how to rotate it in any way.

I will try to see if this works.
The reason I need the angle is because I am using hinge servos to angle my gun