I have a turret on the back of my rover, and I want it to rotate to the mouse’s position. It’s working… slightly. The turret seems to be offset by 45 degrees. Example Below:
(I know how to spell would, there’s just no space)
Ok this is literally the second time today that I solved my own problem because I was capable of doing it but stupid enough to post it. For anyone wondering how I solved it, it wasn’t offset by 45, it was offset by 90. So my code now is:
local delta = CurrentPlayer:GetAttribute("MousePosition") - script.Parent.Turret.Gun.Main.CFrame.Position
script.Parent.TurretHinge.TargetAngle = math.deg(math.atan2(-delta.Z, delta.X)) - 90
If you need to do this it's probably because of the starting angle of your hinge constraint