Why is my arm pointing script not working?

Hi, I was trying to make a game where you can point your arm, so I found a script, modified it to work for R6, and then tried to make it move both arms, but it for some reason broke whit no error in the output.

Local script in SCR:

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 armOffset2 = char.Torso.CFrame:Inverse() * char["Left Arm"].CFrame

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

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

RunService.Heartbeat: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)
	local cframe2 = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld2.C0 = armOffset2 * char.Torso.CFrame:toObjectSpace(cframe2)
end)

Video of it begin broken:

Thanks for your time.

1 Like

I see something wrong in it
Try this

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 armOffset2 = char.Torso.CFrame:Inverse() * char["Left Arm"].CFrame

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

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

RunService.Heartbeat: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)
	local cframe2 = CFrame.new(char.Torso.Position, mouse.Hit.Position) * CFrame.Angles(math.pi/2, 0, 0)
	armWeld2.C0 = armOffset2 * char.Torso.CFrame:toObjectSpace(cframe2)
end) 

You forgot to parent ur second armweld

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