Looking for an auto-expanding scrolling frame fix

Hello.

Recently, I finally figured out how to make some kind of an auto-expanding scrolling frame, but I have one issue.

Without further explaining, I’ll just how a Gif, what I mean:
ZehHcNYc9U

Basically, if there are 3+ frames, it works perfectly fine, but when there is one frame, the size would display the frame over the whole scrolling frame.
If there are 2 frames, the size of them would be 0.5.

That’s happening with that script:

local function addFrame()
	local clone = script.Frame:Clone()
	clone.Parent = script.Parent.ScrollingFrame
	script.Parent.ScrollingFrame.CanvasSize = UDim2.new(0,0,script.Parent.ScrollingFrame.UIGridLayout.AbsoluteCellCount.Y/6,0)
	script.Parent.ScrollingFrame.UIGridLayout.CellSize = UDim2.new(0.95,0,1/script.Parent.ScrollingFrame.UIGridLayout.AbsoluteCellCount.Y, 0)
end

I know, I could add some if statements if there are 2 frames, or 1, etc, but it there a more efficient way to do it?

Thank you!

Bruh, I just realized that it also shows 6 frames instead of 7 for example (it shows one frame less)

Nvm, solved by using this: