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)