Help making Shoulders rotate around Pivot Point relative to Mouse Y

Hello, I am trying to make a first person camera effect but the methods I’ve tried ended up looking janky. So I concluded that since the point the camera revolves around and zooms into is typically the head of the character, I could make the arms rotate around the head to give off a convincing first person camera effect.


The arms facing relatively to the mouse y of the player’s screen works pretty flawlessly but there’s a problem when you go into First Person mode.


The arms look like they move backwards in the opposite direction to the camera’s LookVector the more you look up, this is because the motor6Ds are rotating around their own unique pivot point as opposed to the camera’s position (which would solve the problem)
Here is my code:

Code
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Char = script.Parent
local Torso = Char:FindFirstChild("Torso")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LerpSpeed = 0.2

local rc0,lc0

RunService.Heartbeat:Connect(function()
	Char["Right Arm"].LocalTransparencyModifier = 0
	Char["Left Arm"].LocalTransparencyModifier = 0
	
	local rightX, rightY, rightZ = Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
	local leftX, leftY, leftZ = Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()

	rc0 = (Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y))	
	Torso["Right Shoulder"].C0 = Torso["Right Shoulder"].C0:Lerp(rc0, LerpSpeed)

	lc0 = (Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-Mouse.Hit.p - -Mouse.Origin.p).unit.y))
	Torso["Left Shoulder"].C0 = Torso["Left Shoulder"].C0:Lerp(lc0, LerpSpeed)
end)

Here’s another diagram if you need more explanation:


I need help with this because I don’t really know trigonometry or how to make a Motor6D revolve around a pivot point (being the character’s head in this case)
Thanks again!

So, the thing is the wonky arms will always happen regardless of where you decide to place the pivot point because the shoulders are attached to the torso, NOT the head. The camera in first person mode positions itself at the position of the characters head, so in order to get rid of the arm offset you would literally have to CFrame the arm positions to that of the head, then offset them. By doing this, the arms look like this:

In an arm handler I made, the code for placing the arms is:

local connectionHandlers = {
        [ARMS_CONNECTIONS.CameraUpdated] = function()
            return Camera.Updated:Connect(function(cf)
                local armsTbl = self.Arms
                local rightArm = armsTbl.Right
                local leftArm = armsTbl.Left
                if rightArm == nil or leftArm == nil then
                    return
                end
                local rightRoot = rightArm:FindFirstChild("Root")
                rightRoot.CFrame = cf * CFrame.new(2, -1.5, -1)
                local leftRoot = leftArm:FindFirstChild("Root")
                leftRoot.CFrame = cf * CFrame.new(-2, -1.5, -1)
            end)
        end,
    }

So, in the end, you already have the best way to rotate the shoulders around a pivot point. The only thing you have to do now is either

  1. Change the CFrame of the arms themselves to match a CFrame relative to the camera position
  2. Change the C0 of the Motor6D to match that of the CFrame relative to the camera position