local i={}function i.Create(i,F,r,G,h)F=F or math.huge G=G or UDim.new(0,0)r=r or Enum.FillDirection.Vertical h=h or defaultButton local A=#i local X=1/A local C=r==Enum.FillDirection.Vertical local W=Instance.new("\070\114\097\109\101")W.Name="\076\105\115\116\070\114\097\109\101"W.BorderSizePixel=0 local E=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")E.Name="\083\099\114\111\108\108\070\114\097\109\101"E.BackgroundTransparency=1 E.BorderSizePixel=0 E.Size=UDim2.new(1,0,1,0)local v=nil local q=nil local l=nil local H=(A-1)/A local R=G.Scale*H local D=G.Offset*H if C then v=UDim2.new(0,0,A/F,0)q=UDim2.new(1,0,X-R,-D)else v=UDim2.new(A/F,0,0,0)q=UDim2.new(X-R,-D,1,0)end E.CanvasSize=v local z={}for i,F in ipairs(i)do local r=h(i,F)r.LayoutOrder=i r.Size=q r.Position=UDim2.new(0,0,(i-1)*X,0)if C then r.Position=r.Position+UDim2.new(0,0,(G.Scale/A)*(i-1),(G.Offset/A)*(i-1))else r.Position=r.Position+UDim2.new((G.Scale/A)*(i-1),(G.Offset/A)*(i-1),0,0)end z[i]=r r.Parent=E end W.BackgroundTransparency=z[1].BackgroundTransparency W.BackgroundColor3=z[1].BackgroundColor3 E.Parent=W return W end
-- Library

local List = {}

function List.Create(list, max, fillDirection, padding, instanceFunc)
	max = max or math.huge
	padding = padding or UDim.new(0, 0)
	fillDirection = fillDirection or Enum.FillDirection.Vertical
	instanceFunc = instanceFunc or defaultButton

	local nList = #list
	local dList = 1 / nList

	local isVertical = (fillDirection == Enum.FillDirection.Vertical)

	local listFrame = Instance.new("Frame")
	listFrame.Name = "ListFrame"
	listFrame.BorderSizePixel = 0

	local scrollFrame = Instance.new("ScrollingFrame")
	scrollFrame.Name = "ScrollFrame"
	scrollFrame.BackgroundTransparency = 1
	scrollFrame.BorderSizePixel = 0
	scrollFrame.Size = UDim2.new(1, 0, 1, 0)

	local canvasSize = nil
	local elementSize = nil
	local extraPosition = nil

	local adj = (nList - 1) / nList
	local scale = padding.Scale * adj
	local offset = padding.Offset * adj

	if isVertical then
		canvasSize = UDim2.new(0, 0, nList / max, 0)
		elementSize = UDim2.new(1, 0, dList - scale, -offset)
	else
		canvasSize = UDim2.new(nList / max, 0, 0, 0)
		elementSize = UDim2.new(dList - scale, -offset, 1, 0)
	end

	scrollFrame.CanvasSize = canvasSize

	local items = {}
	for i, option in ipairs(list) do
		local item = instanceFunc(i, option)
		item.LayoutOrder = i
		item.Size = elementSize
		item.Position = UDim2.new(0, 0, (i - 1) * dList, 0)

		if isVertical then
			item.Position = item.Position + UDim2.new(
				0,
				0,
				padding.Scale / nList * (i - 1),
				padding.Offset / nList * (i - 1)
			)
		else
			item.Position = item.Position + UDim2.new(
				padding.Scale / nList * (i - 1),
				padding.Offset / nList * (i - 1),
				0,
				0
			)
		end

		items[i] = item
		item.Parent = scrollFrame
	end

	listFrame.BackgroundTransparency = items[1].BackgroundTransparency
	listFrame.BackgroundColor3 = items[1].BackgroundColor3
	scrollFrame.Parent = listFrame

	return listFrame
end
