-- Enable this script if you have a multi part gun otherwise remove it


local function weld(x, y)
	local newWeld = Instance.new("Weld")
	newWeld.Part0 = x
	newWeld.Part1 = y
	local CJ = CFrame.new(x.Position)
	local C0 = x.CFrame:inverse()* CJ
	local C1 = y.CFrame:inverse()* CJ
	newWeld.C0 = C0
	newWeld.C1 = C1
	newWeld.Parent = x
end

function weldParts(object)
	if object:IsA("BasePart") then
		weld(script.Parent.Handle, object)
		object.Anchored = false
	else
		for i, c in pairs(object:GetChildren()) do
			weldParts(c)
		end
	end
end

local function weldTool()
	weldParts(script.Parent)
end

script.Parent.Equipped:connect(weldTool)
script.Parent.Unequipped:connect(weldTool)
weldTool()
