How do you get the smallest degree between 2 parts?

Hello, I am currently working on a turret & finished all functions, but I am still running in 1 issue, which has to do with the following.
Basically I got 2 parts/CFrames, with the same position, but different orientation at the time.
image image
Now I want to know the degrees in between both parts (Indicated as the green line).

The blue part being the startOrientation & the red part being the endOrientation
Any help would be apreciated.

A good search term to find this out yourself is “angle between vectors.” Maybe include Roblox in the search. But this should be the solution you want.

local angle = math.acos(partA.CFrame.lookVector:Dot(partB.CFrame.lookVector))
1 Like