Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Best way to fragment a part/model into multiple parts?

My game is designed to blow stuff up, that being said; I've made a big house and the walls in it are solid and close to impossible to knock down with explosives. I cannot seem to find the right math to make an 8x8 block into multiple 2x2 blocks in the same position/color/property.

1 answer

✓ Accepted answer

If you're trying to split up a cube, then the following should work.

function splitCube(block, divisions)
	for x = (-divisions/2+0.5), (divisions/2) do
		for y = (-divisions/2+0.5), (divisions/2) do
			for z = (-divisions/2+0.5), (divisions/2) do
				local p = block:Clone()
				p.Parent = block.Parent
				p.Size = block.Size / divisions
				p.CFrame = block.CFrame + (Vector3.new(x, y, z) * (p.Size.x))
			end
		end
	end
				
	block:Destroy()
end

The +0.5 is down to the way position is in the centre of a part, not the edge.

Alternatively, you could increase the BlastPressure of whatever explosions you're using.

1 comment

1

Works perfectly, you're a godsend. I won't forget this, thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.