Hey I'm learning nested loops. Can you help me understand why do I need X, Y and Z instead of just Y. Parts spawn on each other.
local CUBE_SIZE = 2
function makecube()
local cube = Instance.new("Part")
cube.Size = Vector3.new(CUBE_SIZE, CUBE_SIZE, CUBE_SIZE)
cube.Color = Color3.fromRGB(255, 255, 0)
cube.CFrame = CFrame.new()
cube.Parent = game.Workspace
end
for heightIndex = 1, TOWER_SIZE do
local spawnY = (heightIndex - 1) * CUBE_SIZE
for heightIndex = 1, TOWER_SIZE do
local spawnY = (heightIndex - 1) * CUBE_SIZE
for lengthIndex = 1, TOWER_SIZE do
local spawnX = lengthIndex * CUBE_SIZE
for widthIndex = 1, TOWER_SIZE do
local spawnZ = widthIndex * CUBE_SIZE
makecube(spawnX, spawnY, spawnZ)
task.wait(0.25)
end
end
end
end```