you could try target.orientation.X - part.orientation.X sine than it will calculate the angle diffrence between the 2 parts if u want part to look at the target you could do part.Cframe = CFrame.new(part.CFrame , target.CFrame)
only thing i would change is id use the both part’s positions instead of CFrame.
Then instead of using toObjectSpace id just do (partPos - targetPos) .Unit.
ps. if you’re trying to find the angle from the part to the target (part as the origin) then the equation becomes (targetPos - partPos).Unit
pps. You dont need to use .Unit on lookvector/rightvector/upvector because they are already a unit vector
while task.wait() do
local partA = target.CFrame
local partB = part.CFrame
local x = partA.Position.X
local x2 = partB.Position.X
local z = partA.Position.Z
local z2 = partB.Position.Z
print(math.deg(math.atan((x-x2) / (z-z2))))
end
target is the second part, [part] is the main part, i need to find the angle between [part] and target so i can usr motor on a hinge constraint, dont worry abt that for now tho. And I just started using cos, tan, sin, and their inverse functions not too long ago so im fairly new to the concept of trig in roblox studio.
I can try that when im home (first period just started), but what’s the difference between acos and asin, and why would acos work for this?(no argument, just curious)