I need help with this script

Hi I am making this Combat system And I have ran into trouble I was making this R15 and then I changed my mind and decided to make it R6. But when I change RightHand Into Right Arm I am getting a error and the script breaks if there is any way to change the weld script tell me.

local function setUp(char)
	local handle = fx.Handle:Clone()
	handle.Parent = char
	local m6d = Instance.new("Motor6D", handle)
	m6d.Part0 = char.RightHand
	m6d.Part1 = handle
	m6d.C1 = CFrame.new(0,.125,0)
	local model = fx.MeshPart:Clone()
	model.Parent = workspace.Fx
	local weld = Instance.new("Weld", model)
	weld.Part0 = handle
	weld.Part1 = model
	weld.C1 = CFrame.new(-0.20,-0.25,2.25) * CFrame.Angles(math.rad(0),0,80)
end

for i,v in pairs(game.Players:GetChildren()) do
	repeat wait() until v.Character
	setUp(v.Character)
	v.CharacterAdded:Connect(function(char)
		char:WaitForChild("Right Arm")
		setUp(char)
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char:WaitForChild("Right Arm")
		setUp(char)
	end)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I see your issue in your “setUp” function. You are setting m6d.Part0 to char.RightHand which doesn’t exist if this is r6.

2 Likes

oh, how do I fix this issue? what should I use? instead

Change this to:
m6d.Part0 = char["Right Arm"]

1 Like
CFrame.Angles(math.rad(0),0,80)

Unrelated but math.rad(0) is 0 Radians and 80 Radians is 14,400 Degrees.

CFrame.Angles(0, 0, math.pi/2)

Assuming you want a 90 degree rotation around the Z-axis.