Move players right arm with the mouse's Y position R6

Hello fellow developers,
I just thought of a way to rotate the player arm’s Y position according to the mouse’s Y position. After some research I came up with this script:

local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local char = script.Parent
local torso = char:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")

local function updateArmRotation()
	local angle = math.rad((mouse.UnitRay.Direction.Y * 100) / 2)

	rightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.rad(90), angle)
end

game:GetService("RunService").RenderStepped:Connect(updateArmRotation)

It uses mouse.UnitRay (which I myself dont really know how it works), takes the Y position of the direction of the ray, multiplies it with 100 and then divides it by 2. math.rad() is used for CFrame.Angles(). After that it takes the initial position of the shoulder motor and multiplies it with CFrame.Angles() to get the rotation. The function is connected to RunService.RenderStepped to update the rotation of the arm every frame.

This is a LocalScript, put into StarterCharacterScripts.

This feels really niche, why specifically the players right arm only on the Y axis?
This post generally feels like a ‘look what I just figured out’… without actually being something people could confidently use.

I ain’t hating on it, I just don’t think it should be this amounts of specific.

I posted it since I had the same problem of not finding a simple solution for this problem. I saw many posts asking about this problem but most of them were unsolved and since I needed it for my game I tried doing it myself. I just wanted to post it for other players who want to have the same effect.

You can also easily add other limbs or other rotations. It just ended up like this since I needed it that way.