ScrollingFrame's Y size (CanvasSize) refuses to change

Hi! I’m wondering if there’s any way to make a ScrollingFrame’s Y size expand based on its children?
I don’t want to be limited as I want to add more children in the future, but the ScrollingFrame is not long enough.

I’ve been trying to research this on the DevForum already, but there doesn’t seem to be a valid solution for my issue.
And no, I am not using any objects to control the children within the frame (UIListLayout etc etc.)


Any replies to this thread is appreciated.

There is a property of ScrollingFrame’s called " AutomaticCanvasSize" try this:

ScrollingFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y

That doesn’t work, it only makes it worse and more buggy when adding more children to it.
I only want the scrolling to be longer.

Have you looked at the GetChildren() function? That just basically returns all the Children inside a specific Instance, (In your case, the ScrollingFrame object)

local ScrollingFrame = script.Parent.ScrollingFrame

local GetChildren = #ScrollingFrame:GetChildren()

We actually put a # symbol here, as we only want the length (Or amount of Instances) inside the ScrollingFrame

Depending on how far you really want your Size to go, you could maybe set a base value so that it doesn’t exceed too much:

local ScrollingFrame = script.Parent.ScrollingFrame

local GetChildren = #ScrollingFrame:GetChildren()
local BaseSize = ScrollingFrame.Size.Y

ScrollingFrame.Size.Y = (BaseSize * GetChildren) / 10

(Disclaimer: I am just guessing here I’m assuming this is what you want perhaps?)

I would do that but I don’t need to resize the ScrollingFrame itself, I only need a way to expand the scrolling length of the frame.

I think you’d need to use some sort of hacky situation to get just the “scrolling length”, I’m not sure how but the majority of the posts recommend using some UILayout object

Either that or it just isn’t possible :pensive:

That wouldn’t work either, apparently nothing works when it comes to expanding the scrolling length.

What do you mean buggy? Try a UI List Layout. It will automatically push it down the Y if setup properly.

Refer to the OP:

She doesn’t want (I’m assuming) to use any UI Layouts of any sort

I’d recommend using a UIListLayout or similar other classes. They all have a property called AbsoluteContentSize which you can use to set the canvas size accordingly.

local scrollingFrame = --The Frame
local listLayout = --The list layout

local function updateSize()
    local content = listLayout.AbsoluteContentSize
    scrollingFrame.CanvasSize = UDim2.fromOffset(content.X, content.Y)
end

updateSize()
listLayout:GetPropertyChangedSignal('AbsoluteContentSize'):Connect(updateSize)

With the method above, adding or removing items will automatically change the scrolling frame’s CanvasSize accordingly.

Is there a reason you don’t want to use a UILayout item? I’m curious as to what your use case is for adding items dynamically yet not wanting to use one.

Without one, your best solution is adding up the sizes and positions inside the scrolling frame, and trying to guess the proper CanvasSize that way.

With the method above, adding or removing items will automatically change the scrolling frame’s CanvasSize accordingly.

Yes, but that wouldn’t really solve anything because I’m already able to change the CanvasSize, I just want the scrolling to somehow expand based on a property of the ScrollingFrame, but that doesn’t seem to be possible. :confused:

Is there a reason you don’t want to use a UILayout item? I’m curious as to what your use case is for adding items dynamically yet not wanting to use one.

I can’t use a UIListLayout/Grid because they are bugged, meaning if you resize the GUI, the children will automatically sort themselves and look very off at the end.

Could you explain / provide an example of the behavior you want? I’m confused as to exactly what you want the scrolling frame to do. A before / after mockup would be great.