Voxel destruction script help

I’m very new to lua and still getting the hang of some things, and I’ve been using this modulescript for voxel destruction stuff and it works absolutely perfect, though theres this one bug that i cant figure out without breaking the entire thing, its probably something extremely simple.

So the issue here is whenever the parts get split up, the split parts are always 25% taller then they’re supposed to be. I need the voxel size to be exactly 1, 1, 1, but it keeps coming out to 1, 1.25, 1. This isn’t my script, and all the other voxel destruction scripts either dont work, or aren’t what i need, or i don’t know how to use them if they don’t have any sort of instructions of any kind.

Here is the modulescript i’m using.

local module = {}
module.VoxelSize = 1

function module:_clonePart(template): BasePart
	local part = template:Clone()
	part.Parent = template.Parent

	return part
end

function module:_getPartsInBounds(cframe: CFrame, size: Vector3 | number, params: OverlapParams?): {BasePart}
	if tonumber(size)  then
		return workspace:GetPartBoundsInRadius(cframe.Position, size, params)
	else
		return workspace:GetPartBoundsInBox(cframe, size, params)
	end
end

function module:DividePart(part: BasePart, axis: Vector3)
	local a = module:_clonePart(part)
	local b = module:_clonePart(part)

	a.Size = part.Size * (-(axis/2)+Vector3.new(1,1,1))
	a.CFrame = part.CFrame * CFrame.new(-part.Size * (Vector3.new(1,1,1)*axis/4))	

	b.Size = part.Size * (-(axis/2)+Vector3.new(1,1,1))
	b.CFrame = part.CFrame * CFrame.new(part.Size * (Vector3.new(1,1,1)*axis/4))	
end

function module:SubdivdePart(part: BasePart, size: number?): boolean
	size = size or module.VoxelSize
	if part.Size.X / 2 < size and part.Size.Y / 2 < size and part.Size.Z / 2 < size then return false end

	local axis = math.max(part.Size.X, part.Size.Y, part.Size.Z)
	if axis == part.Size.X then
		module:DividePart(part, Vector3.new(1,0,0))
	elseif axis == part.Size.Y then
		module:DividePart(part, Vector3.new(0,1,0))
	else
		module:DividePart(part, Vector3.new(0,0,1))
	end

	part:Destroy()
	return true
end

function module:PartDividable(part: BasePart)
	if not part:IsA("Part") then return end
	if part.Shape ~= Enum.PartType.Block then return end
	if part.Parent:FindFirstChildOfClass("Humanoid") then return end
	if part.Parent:IsA("Accessory") then return end
	if part:HasTag("NonDestructible") then return end

	return true
end

function module:DestroyPartsInBounds(cframe: CFrame, size: Vector3 | number, params: OverlapParams?, voxelSize: number?, callback: (BasePart) -> ()?)
	local parts
	repeat
		parts = module:_getPartsInBounds(cframe, size, params)
		if #parts == 0 then break end
		for i = 1, #parts do
			if module:PartDividable(parts[i]) then
				local divided = module:SubdivdePart(parts[i], voxelSize)
				if not divided then 
					if callback then
						callback(parts[i])
						parts[i] = nil
					else
						parts[i]:Destroy()
					end
				end
			else
				parts[i] = nil
			end
		end
	until #parts == 0
end

return module

The original creators place is voxel destruction - Roblox and in their youtube tutorial i could see it had the same issue.

Here’s just a video of what the issue is, ignore my bad display name it was a joke for something

External Media

Anyways, I just need the parts to be the correct size, if anyone has any suggestions, tutorials, fixes etc that would be greatly appreciated.

(this is one of my first times posting on the dev forum so idk if i’m doing this right)

Edit: the video didnt imbed for some reason so here is an edited version that will fit here.

Added a shortened video and more info because a friend said they didnt have access to the link, hope you can see what i mean now.

The creator of this method actually contacted me back, and he said “unless all your parts are perfect squares theres always going to be a little bit of stretching because of how it divides parts. If you have a 3,1,1 part with a voxel size of one its always going to be cut into 2 1.5,1,1 parts and stop there since if it went lower the size of any given axis would be smaller than 1. You might be able to fix the issue by doing some rounding magic, if you need any help my discord is in the description, feel free to ask.” So, it sounds like this issue is unfixable without fully re-doing the entire voxel module. I’ve turned to a different, more advanced module, VoxelDestruct | Voxelated destruction physics with greedy meshing, hitboxes, and more!, that works way better in my opinion, and much more efficient and versatile, especially for what i need from it.