local e={}function e.Create(e,S,c,Y,R)S=S or math.huge Y=Y or UDim.new(0,0)c=c or Enum.FillDirection.Vertical R=R or defaultButton local w=#e local f=1/w local y=c==Enum.FillDirection.Vertical local Z=Instance.new("\070\114\097\109\101")Z.Name="\076\105\115\116\070\114\097\109\101"Z.BorderSizePixel=0 local F=Instance.new("\083\099\114\111\108\108\105\110\103\070\114\097\109\101")F.Name="\083\099\114\111\108\108\070\114\097\109\101"F.BackgroundTransparency=1 F.BorderSizePixel=0 F.Size=UDim2.new(1,0,1,0)local h=nil local O=nil local G=nil local t=(w-1)/w local z=Y.Scale*t local N=Y.Offset*t if y then h=UDim2.new(0,0,w/S,0)O=UDim2.new(1,0,f-z,-N)else h=UDim2.new(w/S,0,0,0)O=UDim2.new(f-z,-N,1,0)end F.CanvasSize=h local m={}for e,S in ipairs(e)do local c=R(e,S)c.LayoutOrder=e c.Size=O c.Position=UDim2.new(0,0,(e-1)*f,0)if y then c.Position=c.Position+UDim2.new(0,0,(Y.Scale/w)*(e-1),(Y.Offset/w)*(e-1))else c.Position=c.Position+UDim2.new((Y.Scale/w)*(e-1),(Y.Offset/w)*(e-1),0,0)end m[e]=c c.Parent=F end Z.BackgroundTransparency=m[1].BackgroundTransparency Z.BackgroundColor3=m[1].BackgroundColor3 F.Parent=Z return Z end


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
