How can i get arm to point to vector3 (r6)

Im trying to get the players right arm to point towards the mouse position but for some reason no matter what i try i can not get it to work.
i have tried multiple solutions but none of them have worked for me.
here is the solution that i tried which for some reason didnt work:

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 RightShoulder = Player.Character.Torso['Right 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))
end)

i also tried making my own solution which also did not work. here is my solution:

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)

any help would be appreciated.

Hey hey hey I noticed where that code came from.

Shouldn’t the CFrame angles be math.rad(90) and not math.deg(-90)?

1 Like

Hm I thought you could do this with something like IKControls too. I haven’t tried it myself but uh yknow