function placeBrick(H,i,X)local u=Instance.new("\080\097\114\116")u.BrickColor=X u.CFrame=H*CFrame.new(i+u.size/2)u.Parent=script.Parent.Bricks u:makeJoints()return u,i+u.size end function buildWall(H)local i=BrickColor.random()local X={}assert(wallWidth>0)local u=0 while u<wallHeight do local E local B=-wallWidth/2 while B<wallWidth/2 do local Y Y,E=placeBrick(H,Vector3.new(B,u,0),i)B=E.x table.insert(X,Y)wait(brickSpeed)end u=E.y end wait(wallLifetime)while#X>0 do(table.remove(X)):remove()wait(brickSpeed/2)end end script.Parent.ChildAdded:connect(function(H)if H.Name=="\078\101\119\087\097\108\108"then H:remove()buildWall(H.Value)end end)
-- places a brick at pos and returns the position of the brick's opposite corner
function placeBrick(cf, pos, color)
	local brick = Instance.new("Part")
	brick.BrickColor = color
	brick.CFrame = cf * CFrame.new(pos + brick.size / 2)
	brick.Parent = script.Parent.Bricks
	brick:makeJoints()
	return brick, pos + brick.size
end

function buildWall(cf)
	local color = BrickColor.random()
	local bricks = {}

	assert(wallWidth > 0)
	local y = 0
	while y < wallHeight do
		local p
		local x = -wallWidth / 2
		while x < wallWidth / 2 do
			local brick
			brick, p = placeBrick(cf, Vector3.new(x, y, 0), color)
			x = p.x
			table.insert(bricks, brick)
			wait(brickSpeed)
		end
		y = p.y
	end

	wait(wallLifetime)

	-- now delete them!
	while #bricks > 0 do
		table.remove(bricks):remove()
		wait(brickSpeed / 2)
	end
end

script.Parent.ChildAdded:connect(function(item)
	if item.Name == "NewWall" then
		item:remove()
		buildWall(item.Value)
	end
end)
