How can I improve the performance of this weld script?

So I have this module script that is responsible for heavy duty work which is welding surfaces on heaps of parts.

Currently, this causes some pretty big lag spikes from all the welds being created. There can be as much welds as 5000 weld constraints too. Is there anything I can do to reduce this?

local Offset = 0.05

local OffsetVectorX = Vector3.new(Offset, -Offset, -Offset)
local OffsetVectorY = Vector3.new(-Offset, Offset, -Offset)
local OffsetVectorZ = Vector3.new(-Offset, -Offset, Offset)

local function CreateWeld(PartA, PartB)
	local Weld = Instance.new("WeldConstraint")
	Weld.Part1 = PartA
	Weld.Part0 = PartB
	Weld.Parent = PartA
end

-- Per descendant part function
local function SurfaceWeldPart(Part)
	if Part:IsA("BasePart") then
		Params.FilterDescendantsInstances = {Part}

       -- Check if one of the surfaces are being touched
		local PartsX = workspace:GetPartBoundsInBox(Part.CFrame, Part.Size + OffsetVectorX, Params)
		local PartsY = workspace:GetPartBoundsInBox(Part.CFrame, Part.Size + OffsetVectorY, Params)
		local PartsZ = workspace:GetPartBoundsInBox(Part.CFrame, Part.Size + OffsetVectorZ, Params)
		
		for i, PartToWeldToX in pairs(PartsX) do
			CreateWeld(Part, PartToWeldToX)
		end

		for i, PartToWeldToY in pairs(PartsY) do
			CreateWeld(Part, PartToWeldToY)
		end

		for i, PartToWeldToZ in pairs(PartsZ) do
			CreateWeld(Part, PartToWeldToZ)
		end
	end
end

function SurfaceWeldModule.WeldModel(Model: Model)
	for i, Part in pairs(Model:GetDescendants()) do
		SurfaceWeldPart(Part)
	end
end

Could this work? Model | Roblox Creator Documentation

Just use qPerfectionWeld , in the script @Quenty said that it takes careful measure to reduce lag

Its not a surface weld and also im pretty sure it uses the deprecated weld instance. I want to specifically optimise this script

That uses the deprecated surface joints that this script is suppose to replace