Having Trouble pivoting the player's shoulders to face their mouse

I’ve wanted the player’s shoulders to pivot around their torso, facing their mouse on the X(?) axis.. I’m not that fluent in CFrame/Motor6D terminology so I’ve made a video that hopefully explains what I’m trying to describe below:
Goal|image

I have tried to read up on the Developer Documentation, but most information is stuff I can’t really understand and things that don’t help me. I’ve tried using a solution I found online (which turned out to be undesirable as you can see in the video below)

The bad code that changes the Motor6D properties:

-- Pre-defined
local root: BasePart = character:WaitForChild("HumanoidRootPart")
local rshoulder: Motor6D = torso:WaitForChild("Right Shoulder")
local lshoulder: Motor6D = torso:WaitForChild("Left Shoulder")
local RC0, LC0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0), CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
local RC1, LC1 = CFrame.new(-.5, .5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0), CFrame.new(.5, .5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)

-- Runs in a Renderstep loop
local rootJoint: Motor6D = root:FindFirstChild("RootJoint")

local cDir = root:GetPivot():ToObjectSpace(mouse.Origin).LookVector
local _, _, z = rootJoint.Transform:ToOrientation()

rshoulder.C0 = CFrame.lookAt(RC0.Position, cDir * 400) * CFrame.Angles(0, math.rad(90) + z, 0)
lshoulder.C0 = CFrame.lookAt(LC0.Position, cDir * 400) * CFrame.Angles(0, -math.rad(90) + z, 0)

All the other solutions I’ve thought of so far haven’t gone anywhere and I’ve come to a roadblock in my mind for thinking of/finding new ones across the internet

EDIT: made some wording changes and fixed some inaccuracies

I still haven’t found any solutions and I don’t know what to do in terms of getting people to be able to see this again. Sorry if this is considered ‘necroposting’

the l shoulder is also the right shoulder according to ur script?.

Whoops, didn’t catch that. Since this code was from a month ago I’ve already fixed this, but forgot to update the DevForum post. Thanks.

1 Like