local g=ParentContainer.Attribs.ResizeEvent local T=5 local X=.25 local E=6 local a=32 function getNewCellSize()X=Container.AbsoluteSize.X/T-E end function updateLayout()getNewCellSize()local s=Container.Cells:GetChildren()for g,a in pairs(s)do local s=g-1 local c=(s%T)*(X+E)+E/2 local O=math.floor(s/T)*(X+E)+E/2 a.Size=UDim2.fromOffset(X,X)a.Position=UDim2.fromOffset(c,O)end local c=math.ceil(#s/T)local O=UDim2.new(1,-24,0,(c*X+E)+a)Container.Size=O g: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)
-- EVENTS --
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)
