Arms following mouse not working with animations

So I have a script to make the player’s arm’s follow the mouse
And it works how it should without any animations.

But when I add an idle animation, it starts the arms starts rotating the wrong axis.

Here’s the script:

local x = -(math.asin((camera.CFrame.Position - mouseHit).unit.y))
local _, y, z = rightShoulder.C0:ToEulerAnglesXYZ()
				
rightShoulder.C0 = CFrame.new(rightShoulderC0.Position) * CFrame.Angles(x, y, z)
		
toolGrip.C0 = rightShoulder.C0 * CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(-1,-0.5,0)

local _, y, z = leftShoulder.C0:ToEulerAnglesXYZ()
leftShoulder.C0 = CFrame.new(leftShoulderC0.Position) * CFrame.Angles(x, y, z)
1 Like

As you can see, it works how it should without animations.

1 Like

bumping this. if anyone has a solution please drop it here

the problem happens because the motor6d cframe is relative to the cframe of the body part its attached to

so you can cancel it out by multiplying by the inverse of the cframe of the attached part

--example
arm.CFrame = CFrame.new() * torso.CFrame:Inverse() -- because its attached to the torso