Hi! So essentially what I'm trying to do is angle the arm on the y axis so that it points up towards where the mouse is pointed.
I've worked it out like this so far, and it goes in the right direction, but it's not on the mark with where the mouse is. Any help would be appreciated
Here's the function that I run in a Stepped loop:
local PositionArm = function(goal)
local arm = character.RightUpperArm
local shoulder = arm.RightShoulder
local distanceX = goal.X - arm.Position.X
local distanceY = goal.Y - arm.Position.Y
local distanceZ = goal.Z - arm.Position.Z
local angleY = math.atan(distanceY/math.sqrt((distanceZ^2) + (distanceX^2)))
print(angleY)
shoulder.Transform = CFrame.Angles(math.deg(angleY), 0, 0)
end

1 comment
Goal is the mouse, fyi