Ways to fill a shape with blocks?

Linking in to my last post, from some help I managed to figure out a good efficient way of splitting my block into parts. What I do is Area / the size of the bricks that I want to fill a shape with which gives me a total number of bricks,

I got the number but is there anyway to transfer all these bricks to the shape position to like fill it up?


Nice idea! You made this look very good man.

You’ll want to start at the lower left front corner and use 3 nested for loops to loop over each position in the volume.

You can get the corner like this:

local left_lower_front_corner = volume.CFrame:PointToWorldSpace( -volume.Size/2 )
local first_block_pos = left_lower_front_corner + Vector3.new(block_size/2, block_size/2, block_size/2)

You can set up the loops like so:

local block_size = 4

local block_prefab = Instance.new("Part")
block_prefab.Anchored = true
block_prefab.Size = Vector3.new(block_size, block_size, block_size)

local volume = script.Parent
local left_lower_front_corner = -volume.Size/2
local first_block_pos = left_lower_front_corner + Vector3.new(block_size/2, block_size/2, block_size/2)

for x = 0, volume.Size.X - block_size, block_size do
	for y = 0, volume.Size.Y - block_size, block_size do
		for z = 0, volume.Size.Z - block_size, block_size do


And create the blocks like this:

local block_offset_objectspace = Vector3.new(x, y, z)
local block_cframe = volume.CFrame * CFrame.new(first_block_pos + block_offset_objectspace)
local block = block_prefab:Clone()
block.Color = Color3.fromHSV(math.random(), 1, 1)
block.CFrame = block_cframe
block.Parent = game.Workspace

Here’s a working example that you can download and drag-n-drop into an open Studio window:
VolumeFiller.rbxm (3.0 KB)


Your honestly a life saver, script works thanks so much!