Rotate arm with rotated torso

before we begin, i’m not good at english, sorry.
i want to make character’s arm follow mouse on y-axis, so i tried code from a youtube tutorial.
but it didn’t work. i guess it’s because character’s torso is rotated. however i don’t know what to do.

i have read a lot of topics about it… but i couldn’t find answer.
video:

my code:

local RunService = game:GetService("RunService")
local PlayerService = game:GetService("Players")
local plr = PlayerService.LocalPlayer
local cam = workspace.CurrentCamera
local chr = plr.Character
local torso:BasePart = chr["Torso"]
local right_shoulder:Motor6D = torso["Right Shoulder"]
local right_shoulder_origin = right_shoulder.C0
local left_shoulder:Motor6D = torso["Left Shoulder"]
local left_shoulder_origin = left_shoulder.C0

RunService.Stepped:Connect(function()
	local camDir = torso.CFrame:ToObjectSpace(cam.CFrame).LookVector
	right_shoulder.C0 = right_shoulder_origin*CFrame.Angles(0,0,camDir.Y)
	left_shoulder.C0 = left_shoulder_origin*CFrame.Angles(0,0,-camDir.Y)
end)

thank you for reading.

1 Like

Why not use the root part instead of the torso if rotation is the issue?

um… i didn’t understand… how can i use root part for this? motor6d(right shoulder) is connecting torso and right arm. could you explain it in more detail? thanks for reply!

You can use it for the angle measurement method, it is relative to torso object space which is the issue. Try replacing it with root part.

still don’t work… camera angle detection is fine. the arms are rotating incorrectly.
my goal:
image
image
wrong way(now):
image