Help with getting arm to point to vector3

im trying to get the players right arm to point towards their cursor position but i cant seem to figure out the CFrame maths to do so.
(i know i probably shouldnt use Mouse.Hit, i am only doing this for testing as i am trying to get it working before writing it properly)

what i have tried so far:

local jointPosition = Shoulder.Part0.CFrame:toWorldSpace(CFrame.new(0.9,0.25,0.25))
local cframe = CFrame.new(jointPosition.p, Mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -1, 0)

Shoulder.C0 = Shoulder.Part0.CFrame:ToObjectSpace(cframe)
local Transform: CFrame = Shoulder.Transform
Shoulder.Transform = Transform:Lerp(CFrame.lookAt(Shoulder.Part0.CFrame.Position,Mouse.Hit.Position).Rotation * CFrame.Angles(math.rad(90),0,0),.1)

Any help would realy be appreciated.

I’m kind of confused but what is “shoulder” I’ve never seen a character part named that. Is this R6 or R15?

Edit: Also which arm? Right or left?

yea could you send the entire script, im not sure if “shoulder” is a variable or if u made like an attatchment or idk, but i dont have enough reference to go off of with just this

The Shoulder is just the Right Shoulder Motor6D that is inside of the players Torso.

The Shoulder is just the Right Shoulder Motor6D that is inside of the players Torso.
also this is running in RunService.PreSimulation incase you wanted to know

ohh i see what your trying to do then, so i think when you change the cframe of a part thats attatched by a motor6d then it destroys the motor6d, so instead try doing C0, instead of Part0 just try rq

and make sure not to do C0.Cframe because C0 is already a cframe value, so just change it to that

I am already setting C0 or Transform, id rather use transform than C0 but if C0 is the only option i can use it.

idk if im doing something wrong but none of these worked 100%. here is the code that i tried which “worked” for someone but wont work for me:

local function Point_C0_To_Mouse(Motor6D, WorldCFrame)
	local Part1_CFrame = Motor6D.Part1.CFrame
	local Stored_C1 = Motor6D.C1
	local Stored_C0 = Motor6D.C0
	local RelativeTo_Part1 = Stored_C0 * Stored_C1:Inverse() * Part1_CFrame:Inverse() * WorldCFrame * Stored_C1
	RelativeTo_Part1 -= RelativeTo_Part1.Position

	local Goal_C0 = RelativeTo_Part1 + Stored_C0.Position
	return Goal_C0
end


game:GetService('RunService').Stepped:Connect(function()
	local RightArm = Player.Character['Right Arm']
	local LeftArm = Player.Character['Left Arm']
	local RightShoulder = Player.Character.Torso['Right Shoulder']
	local LeftShoulder = Player.Character.Torso['Left Shoulder']
	local Mouse_Pos = Mouse.Hit.Position
	RightShoulder.C0 = Point_C0_To_Mouse(RightShoulder, CFrame.lookAt(RightArm.Position, Mouse_Pos)) * CFrame.Angles(0,0, math.deg(-90))
	LeftShoulder.C0 = Point_C0_To_Mouse(LeftShoulder, CFrame.lookAt(LeftArm.Position, Mouse_Pos)) * CFrame.Angles(0,0, math.deg(90))
end)

i also tried writing it myself again but it didnt work either, here is my code:

game:GetService('RunService').Stepped:Connect(function()
	
	local Shoulder: Motor6D = Player.Character.Torso['Right Shoulder']
	local mouseDirection = Player.Character.HumanoidRootPart.CFrame:toObjectSpace(Mouse.Hit).LookVector
	local RightArm = Shoulder.Part1
	Shoulder.Transform = CFrame.new()
	
	local DefaultC0 = CFrame.new(1,.5,0)*CFrame.Angles(0,math.rad(90),0)
	local DefaultC1 = CFrame.new(-.5,.5,0)*CFrame.Angles(0,90,0)
	
	Shoulder.C0 = DefaultC0 * CFrame.lookAt((RightArm.CFrame*(DefaultC1):Inverse()).Position,Mouse.Hit.Position).Rotation * DefaultC1:Inverse()
end)