How to auto size scrolling frame?

  1. What do you want to achieve?
    I want to auto size a scrolling frame depending on how many items(gui elements) are in it.

  2. What is the issue?
    I have no idea on how to do so

  3. What solutions have you tried so far?
    I have tried using LayoutUtil v 2.0 and other scripts i found but all of them made my GUIelements tiny or just broke the entire GUI.
    (I usually don’t copy scripts but I’m not good with GUI’s at all so this is kinda my only option)
    (I’m using Scale on everything already and all the UIConstraints are set by the AutoScale Lite plugin)

1 Like

The AutomaticCanvasSize property should help you. Setting it to Y is sufficient.

1 Like

Exactly what I’m looking for but doesn’t work for me, there wasn’t really any examples on a scrollFrame in the developer forum. I probably did something wrong.
image

1 Like

I don’t understand what’s not working, the image looks OK to me. Or did I interpret your reply incorrectly?

1 Like

Well I guess it works but I cant scroll down since the scrollBar isn’t appearing, my bad for not explaining properly.
CanvasSize isn’t changing either.

1 Like

That’s strange. Can you still scroll down?

1 Like

only if I manually change the canvasSize

The only thing I can think of is ScrollingEnabled being false - is it enabled?

1 Like

Is it a Roblox bug?
Because it has always been enabled.
image
Ill try looking for more scripts online

1 Like

After looking thru like 5 pages of google I found some old school Roblox website where someone posted this script

local ScrollingFrame = script.Parent

ScrollingFrame.CanvasSize = UDim2.new(0, ScrollingFrame.UIListLayout.AbsoluteContentSize.X, 0, ScrollingFrame.UIListLayout.AbsoluteContentSize.Y)

Which updates the size depending on the list absolute size
So I made it to update everytime the absoluteSize changes

local ScrollingFrame = script.Parent

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

It’s better to just set the scrolling frame’s canvas size to UDim2.new(0, 0, 0, 0) and its automatic canvas size to ‘X’, ‘Y’ or ‘XY’.

This has always worked for me.

1 Like