Weld Tool Function Not Working

This function isn’t working.

function WeldTool(tool)
	local children = tool:GetChildren()
	
	local parts = {}
	
	for _, child in pairs(children) do
		if child:IsA('BasePart') then
			table.insert(parts, child)
		end
	end
	
	local primaryPart = tool.PrimaryPart or parts[math.random(1, #parts)]
	
	for index = 1, #parts do
		if parts[index].Name ~= primaryPart.Name then
			local weld = Instance.new('WeldConstraint')
			weld.Part0 = primaryPart
			weld.Part1 = parts[index]

			weld.Name = primaryPart.Name.. 'To'.. parts[index].Name..'Weld'
			weld.Parent = tool
		end
	end
end

It’s meant to weld a tool, but the parts aren’t welded to eachother after I call the function.

The issue fixed itself somehow?

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