I created the following script to convert scrolling frames in my game to automatic canvas size.
for _, scrollingFrame in pairs(game.StarterGui:GetDescendants()) do
if scrollingFrame:IsA("ScrollingFrame") then
local scale = scrollingFrame.CanvasSize.Y.Scale
scrollingFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y
scrollingFrame.CanvasSize = UDim2.fromScale(0,1)
for _, child in pairs(scrollingFrame:GetChildren()) do
if child:IsA("GuiBase") then
child.Size = UDim2.fromScale(child.Size.X.Scale, child.Size.Y.Scale*4)
elseif child:IsA("UIPadding") then
child.PaddingBottom = UDim.new(child.PaddingBottom.Scale*scale,0)
child.PaddingTop = UDim.new(child.PaddingTop.Scale*scale,0)
elseif child:IsA("UIListLayout") then
child.Padding = UDim.new(child.Padding.Scale*scale,child.Padding.Offset)
elseif child:IsA("UIGridLayout") then
child.CellPadding = UDim2.new(child.CellPadding.X.Scale*scale, child.CellPadding.X.Offset, child.CellPadding.Y.Scale*scale, child.CellPadding.Y.Offset)
child.CellSize = UDim2.new(child.CellSize.X.Scale*scale, child.CellSize.X.Offset, child.CellSize.Y.Scale*scale, child.CellSize.Y.Offset)
end
end
end
end
however, many of my frames have uilist layouts or ui grid layouts which makes some frames messed up like this:
(can’t scroll down any further)
(scroll up too far)