Arms not rotating correctly

The arms don’t rotate correctly based off of the camera. If I don’t make x negative, the arms rotate in the opposite direction of the camera.

CODE:

local function getRotationFactor()
	local x, y, z = workspace.CurrentCamera.CFrame:ToOrientation()
	print(-x)
	return -x
end

leftShoulder.C1 = originalLeftArmC1 * CFrame.Angles(getRotationFactor(), 0, 0)
rightShoulder.C1 = originalRightArmC1 * CFrame.Angles(getRotationFactor(), 0, 0)

The arms do rotate correctly on the X, but they also rotate on other axis.

Video:

I just need help with fixing the weird rotation bug. If you really need it I can post the whole script, however it’s 100+ lines and most of it has nothing to do with those 8 lines. Thanks!

It looks like you are rotating globally ish, Look into LookVectors, that should help with the orientation of your arms.

I’ll give that a go and let you know how it turns out.

Ok, so I have no idea what I’m doing. I’m completely lost and I can’t find my solution anywhere. I’ve been working at this for the past couple of days. Do you have anything else that might work?

Here is a snip, Obviously just replace the Waist with the arm, you’ll need two of these.
Replace TorsoLookVector to the arm lookVector.
Of course, put this in a heartbeat or something similar.

local Point = PlayerMouse.Hit.p
local HeadPosition = Head.CFrame.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y

Waist.C0 = Waist.C0:lerp(WaistOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 1.2), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1.2, 0), 1.2 / 2)

I’ll try that out and I’ll get back to you.

I messed around with the values and ended up with a result that kind of works but at the same time doesn’t. It goes up just fine but there are several issues:
-The left arm drifts from the right arm
-The arms get stuck when looking down
-When looking up the arms slowly tilt to the right
Here is my modified code:

rightShoulder.C1 = rightShoulder.C1:lerp(originalRightArmC1 * CFrame.Angles(-(math.atan(difference / distance) * -1.2), (((headPosition - point).Unit):Cross(torsoLookVector)).Y * -1.2, 0), 1.2/2)
leftShoulder.C1 = leftShoulder.C1:lerp(originalLeftArmC1 * CFrame.Angles(-(math.atan(difference / distance) * -1.2), (((headPosition - point).Unit):Cross(torsoLookVector)).Y * -1.2, 0), 1.2/2)		

Here is a video of the code in action:

Once those 3 issues are fixed it should be good. Thanks for your help by the way, you are a life saver. I don’t know what I would have done without you!

Yeah, Im terrible with CFrames, I have to write out all the math on a sheet of paper or just fiddle with the values until it works.

Personally, on my guns, I just rotated the entire upper torso, but you are definitely making progress good luck. Keep me updated.