Help making arms point to mouse (R6)

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I need the arms to point to where the mouse is and it is R6. The arm rotates, but it does not rotate at the joint but instead the center of the part.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that I am not well versed in vector math and how CFrames work. I do know trig, if that helps. All of the things I’ve seen just don’t work and the ones that do are for R15.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked at probably 20 different posts about it, tried putting in scripts from toolbox, even tried modifying scripts to work, but as I don’t know much about vectors and CFrames it was to no avail.

I answered that template so that people can understand easier, I will go more in depth:

So I am going to have the system happen when I hold a gun. I just need help getting the joint to rotate correctly. I modified a script that is meant for R15 but it rotates around the arm’s center, not the joint. Image of rotation currently:Screenshot 2021-11-27 233248
Code:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local plr = Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()

local armOffset = char.Torso.CFrame:Inverse() * char["Right Arm"].CFrame

local armWeld = Instance.new("Weld")
armWeld.Part0 = char.Torso
armWeld.Part1 = char["Right Arm"]
armWeld.Parent = char

RunService.RenderStepped:Connect(function()
	local cframe = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld.C0 = armOffset * char.Torso.CFrame:toObjectSpace(cframe)
end)

If anyone knows how to make it rotate at the joint that would be very helpful. Thanks!

1 Like

Store the C0 of the weld to origin once and just use this?

C0 = CFrame.new(origin, target)

Actually I dont know if that would work since I’ve tried to do this myself and pulled my hair out.