ScrollingFrame not showing all items

I found some similar topics, but I couldn’t resolve them with the suggestions I saw.
I am creating a list of fonts, within Server Script:

for Id, Fonte in pairs(Enum.Font:GetEnumItems()) do
	local TextLabelFonte = FrameFontes.TextLabel:Clone()
	TextLabelFonte.Parent = FrameFontes
	TextLabelFonte.Name = Fonte.Name
	TextLabelFonte.Text = Fonte.Name
	TextLabelFonte.Font = Fonte.Name
end
FrameFontes.TextLabel:Destroy()

When running the script, many items are not being shown at the end:

How to fix this?

The thing that is happening is that the scrolling frame has a fixed CanvasSize, but you can change that by writing some code like this:

local ScrollingFrame = <pathToScrollingFrame>

ScrollingFrame.UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
   ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, ScrollingFrame.UIListLayout.AbsoluteContentSize.Y)
end)
2 Likes

FYI: With the fromOffset constructor you could reduce this into just,

UDim2.fromOffset(0, ScrollingFrame.UIListLayout.AbsoluteContentSize.Y);

the scale axis are simply assigned to 0.

2 Likes

Just wanted to ask, this is still in beta I believe, but can this be used instead when its released?

@ReturnedTrue @WaterJamesPlough

Thanks, but with both suggestions, I’m getting a very spaced result, and at the end, the items are not being shown yet:

This constructor and fromScale aren’t correlated to that, they’re live and I’ve been using them throughout my code.

1 Like

Sorry, the excessive vertical space I mentioned was due to my original TextLabel was set with a Size.Scale.Y.
Changing from Scale to Offset, solved the problem:

Looking at the same problem, I found this thread that I created myself over 1 year ago.
However, I found that the solution would be simpler for my problem:
I would just activate ScrollingFrame | Roblox Creator Documentation.