<iframe src="https://giphy.com/embed/f4U4ownjH8ZrtR1001" width="480" height="315" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/f4U4ownjH8ZrtR1001">via GIPHY</a></p>
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
I solved it by adding 90 degrees to the angle:
shoulder.Transform = CFrame.Angles(vertAngle + math.rad(90), 0, 0)