How do I scale a scrollingframe depending on how many children/gui elements it has?

So I have a scrollingframe with a UIGridlayout and a UIPadding, I want to scale the ScrollingFrame’s CanvasSize so that all the gui elements fit in the ScrollingFrame correctly and do not clip. I have tried to use the property AutomaticCanvasSize, but it did not work as I have a UIPadding. I have tried a localscript saying

script.Parent.CanvasSize = UDim2.new(0, 0, 0, script.Parent.UIGridLayout.AbsoluteContentSize.Y)

But it doesn’t work as, there is a massive gap between each line row

I have for now removed the UIPadding and made the AutomaticCanvasSize set to Y but if anyone knows a way for me to keep the UIPadding and the Ui elements still fit in the scrollingframe correctly, that would be much appreciated!

1 Like

Automatic Canvas Size

https://create.roblox.com/docs/reference/engine/classes/ScrollingFrame#AutomaticCanvasSize

2 Likes

This doesn’t work with UIPadding

It should. And if it doesn’t then just have a frame as its parent and size it to be the same size, and apply the padding to that.


This is what it does with a uipadding, also im not show what the second bit means, sorry I dont do ui :sob:

Add a little to the CanvasSize to compensate for the UIPadding then along with AutomaticSize

Yeah it does. Okay, so just apply UI Padding (the Instance) to the scrolling frame, and up the bottom padding. It should work.

This also works. (The limit yk)

image

not difficult

Thank you so much, this worked!

Yep, no worries. Have a blessed rest of your day, God bless :pray:

Umm so, im stupid, it worked but only for the bottom part, the top part is now clipping

It’s clipping even more now

Use UIPadding for the top of the frame.

As in the scrollingframe? This is how I have it rn
image

Also this is the UIPadding:
image

Yes in the scrolling frame, edit the PaddingTop.
And also don’t put that much bottom padding

Scale is out of 0 - 1, one representing the entire size. So if you do more than one you’re going to be doing 110% percent of the size.

Nothing changes even if I increase the Top
image
even if I increase it like this much

I need to so that I can add the UiStroke without it clipping

Do this for the padding.

PaddingBottom:
Scale: 0.05

PaddingTop:
Scale: 0.05