How to make R6 rig point their arm at you

i thought you used IK controll for this, appearently not.
How would i make my R6 rig point their hand at you?

1 Like

Have you considered using ChatGPT or other LLM’s

provided by GPT-4o (likely to not be completely functional, however from my judgement it’s definitely close to completion

local character = script.Parent  -- Assuming this script is a child of the character
local target = workspace.Target  -- Replace with your target object

local function pointHandAtTarget()
    local rightArm = character:FindFirstChild("Right Arm")
    local torso = character:FindFirstChild("Torso")
    local rightShoulder = torso:FindFirstChild("Right Shoulder")

    if rightArm and rightShoulder and target then
        -- Get the position of the torso and the target
        local torsoPosition = torso.Position
        local targetPosition = target.Position

        -- Calculate the direction vector from the torso to the target
        local direction = (targetPosition - torsoPosition).unit

        -- Calculate the angle to rotate the arm towards the target
        local lookVector = torso.CFrame:VectorToObjectSpace(direction)
        local angle = math.atan2(lookVector.Y, lookVector.X)

        -- Create a CFrame to point the arm towards the target
        local newCFrame = CFrame.Angles(0, 0, angle)

        -- Apply the CFrame to the right shoulder joint
        rightShoulder.C0 = rightShoulder.C0:Lerp(newCFrame, 0.5)
    end
end

-- Call the function to point the hand at the target
pointHandAtTarget()

1 Like

i dont like using AI for my games

1 Like

Personally, I use the rig’s Motor6D joints with weld constraints

Motor6D uses CFrames to function, allowing for Lerp or TweenService.
For the Weld Constraint, you connect it to the same parts as the Motor6D ones are connected too

(welds prevent the default animations from overriding your custom stuff

…then consider watching some scripting tutorials because coming back to the devforum every time you need anything done isn’t going to help you

1 Like

ive been scripting for months i dont need tutorials, im just busy so i was putting this off untill i wasnt and chekc to seei if a got an answer

1 Like

Hi,

You can use CFrame.lookAt() combined with the C0 offset property of the Motor6D that creates the joint for the arm to point it at something.

Here’s an example script I made which should be parented to the character you are using. You can set the lookAtTarget to any part you want the limb to point at. It’s currently configured to make the left arm point at something, though with some adjustments you could use other limbs.

local humanoidRootPart = script.Parent.HumanoidRootPart
local leftShoulder = script.Parent.Torso["Left Shoulder"]
local baseOffset = leftShoulder.C0

local lookAtTarget = workspace.LookAt --This is what the arm points at

while true do
	
	leftShoulder.C0 = CFrame.lookAt(baseOffset.Position, lookAtTarget.Position - humanoidRootPart.Position) * baseOffset.Rotation * CFrame.Angles(0, 0, math.rad(-90))
	task.wait()
	
end

Here’s an example video of the desired outcome:

hey wwwaylon, thanks mans ill try it later.
Message me somtime, i wanna keep in touch mans

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.