How to make R6 arm follow the mouse?

Hey guys! I am making a gun and I want the right arm to follow the player mouse. I don’t just want it to move up and down, I also want left and right and stuff. The code below just isn’t working…

local rs = game:GetService("RunService")

local plr = game.Players.LocalPlayer

local char = plr.Character

local mouse = plr:GetMouse()

local torso = char:WaitForChild("Torso")

local armOffset = char.Torso.CFrame:Inverse() * (char["Right Arm"].CFrame * CFrame.new(0,0.25,-0.5))

local armWeld = Instance.new("Weld")

armWeld.Part0 = torso

armWeld.Part1 = char:WaitForChild("Right Arm")

armWeld.Parent = char

rs.Heartbeat:Connect(function()

local cframe = CFrame.new(torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)

armWeld.C0 = armOffset * torso.CFrame:toObjectSpace(cframe)

end)
1 Like

Try the Search button up top…
I typed in “make r6 arm follow mouse” and found so many previous post about this same topic.

They all either only move up and down or don’t work at all.

Not helpful because I’m not that good at trigonometry.

where you able to figure out this problem?