Pointing a players arm towards a part

Dunno dude, the threads picking up pace. I’m mashing stuff here together to try and find a conclusive answer.

1 Like

If i smush some things together based on your final awnser and the reply fron @Z_lqify , I come up with this (plus some edits from me):

local shoulder: Motor6D = character["LeftUpperArm"]["LeftShoulder"];
local cframe = CFrame.lookAt(Shoulder.Position,LookAtPart.Position)
shoulder.C0.CFrame = cframe
1 Like

Cant we just do it like this?

local shoulder = character.LeftUpperArm
local cframe = CFrame.lookAt(Shoulder.Position,LookAtPart.Position)
RunService.RenderStepped:Connect(function()
shoulder.CFrame = cframe
end)
1 Like

Yes, that’s exactly the same as before.

This does not work. This is the exact code I made from his example and has the same result mentioned.

Now I understand what was done with shoulder: Motor6D. It defines the instance type that it has to be.

local RunService = game:GetService("RunService")
local shoulder = character.LeftUpperArm
local cframe = CFrame.lookAt(Shoulder.Position,LookAtPart.Position)
RunService.RenderStepped:Connect(function()
shoulder.CFrame = cframe
end)

Try this

local shoulder = character.LeftUpperArm.LeftShoulder
local cframe = CFrame.lookAt(Shoulder.Position, LookAtPart.Position)
shoulder.C0 = cframe

Did some research and came up with this.

You will need to use the up vector of the cframe to point with the arm at the part such as so:

function PointTopSide(Position, LookPosition)
	local directionToFace = (Position - LookPosition).Unit
	local worldUp = -Vector3.new(0,1,0)
	local zAxisFace = directionToFace:Cross(worldUp)
	local xAxisFace = directionToFace:Cross(zAxisFace)
	return CFrame.fromMatrix(CPart, xAxisFace, directionToFace, zAxisFace)
end

After using this function you can integrate it with what @daisytheghostchild98 said or what other people have said.

I messed around with my code a bit more, and devised a working solution. Turns out including C0’s orientation caused this to break, quite badly, despite it being overwritten.

Here’s some working code I’ll get to optimizing. This should have come to me sooner.

local shoulder: Motor6D = character["LeftUpperArm"]["LeftShoulder"];
shoulder.C0 = CFrame.lookAt(shoulder.C0.Position, workspace.PointTo.Position)
print("part", shoulder.Part0.CFrame.Position)
print("C0",shoulder.C0.Position)
local jointPosition = shoulder.Part0.CFrame:toWorldSpace(CFrame.new(shoulder.C0.Position))
local cframe = CFrame.new(jointPosition.Position, workspace.PointTo.Position) * CFrame.Angles(math.pi/2, 0, 0)-- * CFrame.new(0, -1, 0)
shoulder.C0 = shoulder.Part0.CFrame:toObjectSpace(cframe)-- * CFrame.new(shoulder.C1.Position)
5 Likes

I appreciate everybody’s help, thank you.

1 Like