local u=ParentContainer.Attribs.ResizeEvent local t=5 local P=.25 local U=6 local b=32 function getNewCellSize()P=Container.AbsoluteSize.X/t-U end function updateLayout()getNewCellSize()local q=Container.Cells:GetChildren()for u,b in pairs(q)do local q=u-1 local T=(q%t)*(P+U)+U/2 local x=math.floor(q/t)*(P+U)+U/2 b.Size=UDim2.fromOffset(P,P)b.Position=UDim2.fromOffset(T,x)end local T=math.ceil(#q/t)local x=UDim2.new(1,-24,0,(T*P+U)+b)Container.Size=x u:Fire(ParentContainer.Name)end Container.Cells.ChildAdded:Connect(updateLayout)Container.Cells.ChildRemoved:Connect(updateLayout);(Container:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(updateLayout)

local ResizeEvent = ParentContainer.Attribs.ResizeEvent

local RowCt = 5
local CellSize = 0.25
local Padding = 6
local ContainerPadding_Bottom = 32

function getNewCellSize()
	 CellSize = (Container.AbsoluteSize.X / RowCt) - Padding
end

function updateLayout()
	--[[
	if #Container.Cells:GetChildren() < 1 then
		Container.Parent.HeaderFrame.Visible = false
	else
		Container.Parent.HeaderFrame.Visible = true
	end
	]]
	getNewCellSize()

	local cells = Container.Cells:GetChildren()
	
	for i, cell in pairs(cells) do
		local index = i - 1
		local posX = ((index % RowCt) * (CellSize + Padding)) + (Padding / 2)
		local posY = (math.floor(index / RowCt) * (CellSize + Padding)) + (Padding / 2)

		cell.Size = UDim2.fromOffset(CellSize, CellSize)
		cell.Position = UDim2.fromOffset(posX, posY)
	end

	local rows = math.ceil((#cells / RowCt))

	local newSize = UDim2.new(1, -24, 0, (rows * CellSize + Padding) + ContainerPadding_Bottom)
	Container.Size = newSize

	ResizeEvent:Fire(ParentContainer.Name)
end


Container.Cells.ChildAdded:Connect(updateLayout)
Container.Cells.ChildRemoved:Connect(updateLayout)
Container:GetPropertyChangedSignal("AbsoluteSize"):Connect(updateLayout)
