How do I make multiple frames just fill the screen

The title says it all

This is the code:

local WindowSize = script.Parent.AbsoluteSize

local RowSize = 35

local AddSize = WindowSize.Y
if AddSize % 2 == 1 then
	AddSize -= 1
end

AddSize /= RowSize

AddSize /= WindowSize.Y

for i = 0, RowSize do
	local Row = Instance.new("Frame", script.Parent)
	Row.Name = tostring(i)
	Row.BackgroundTransparency = 0.5
	Row.Size = UDim2.fromScale(1, AddSize)
	Row.BorderSizePixel = 0
	Row.LayoutOrder = i
end

Although it works, it always goes beyond the screen

This is Video:


Can you help me improve the algorithm?

You have to set IgnoreGuiInset in your ScreenGui to true.

1 Like

I mean the Frame generated by the script will exceed the Gui

Oh! I see what you mean.

You can use a ScrollingFrame so you can scroll through all the items.

Or simply change it to this:

local RowCount = 35

for i = 1, RowCount do
	local Row = Instance.new("Frame", script.Parent)
	Row.Name = tostring(i)
	Row.BackgroundTransparency = 0.5
	Row.Size = UDim2.fromScale(1, 1/RowCount)
	Row.BorderSizePixel = 0
	Row.LayoutOrder = i
end

(Iā€™m not sure what you were trying to do with the AddSize)

1 Like