How to make scrollingframe automatically change canvas size

  1. What do you want to achieve? scrollingframe that automatically changes canvas size

  2. What is the issue? the frames inside the scrollingframe stretch repeatedly

  3. What solutions have you tried so far? i looked for solutions on devforum but none of the scripts work

i tried this but the frames inside the scrollingframe stretch repeatedly

local grid = script.Parent:WaitForChild("UIGridLayout")
local scrollingFrame = script.Parent

local function onContentSizeChanged()
	local absoluteSize = grid.AbsoluteContentSize
	scrollingFrame.CanvasSize = UDim2.new(absoluteSize.X, 0 , absoluteSize.Y, 0)
end

grid:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(onContentSizeChanged)

There’s a property inside ScrollingFrame called automaticCanvasSize. In that property, you can set it to Y, X or both X and Y automatic Canvas Size. (You can check it out on devhub)

Using this scripting method will most likely the guis inside the ScrollingFrame be stretched.

1 Like