For some time now I have been having problems with ScrollingFrames, where the scrolling starts to disappear after adding many items, like in this image:
I searched for a long time and never found any answer, even setting the CanvasSize to AbsoluteContentPosition of the uilistlayout or UIGridLayout, it was still missing.
This works more like a workaround, I didn’t find resources anywhere so I tried my solution, if you have a better solution please tell me.
EXPLANATION
The solution I found is, after the new frame is added I leave the CanvasSize like this:
local OffSet = ScrollingFrame.UIGridLayout.AbsoluteContentSize.Y
ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, OffSet )
Increasing according to the size of the content. Even doing this, the ScrollingFrame (in my case) had the AbsoluteCanvasSize smaller than the indicated OffSet, so I created this function:
local function Resize()
repeat
local Difference = ScrollingFrame.UIGridLayout.AbsoluteContentSize.Y - ScrollingFrame.AbsoluteCanvasSize.Y
local IncriseHate = Difference > 100 and 100 or Difference > 50 and 25 or Difference > 10 and 2 or 1
ScrollingFrame.CanvasSize = UDim2.fromOffset(0, ScrollingFrame.CanvasSize.Y.Offset + IncriseHate)
task.wait()
until ScrollingFrame.AbsoluteCanvasSize.Y >= ScrollingFrame.UIGridLayout.AbsoluteContentSize.Y
end
I put this task.wait() so the script would wait for a beat so that the sculecher would increase the frame size and I tried to reduce it to the smallest number of repetitions possible.
local OffSet = ScrollingFrame.UIGridLayout.AbsoluteContentSize.Y
ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, OffSet )
task.wait()
Resize()
The code itself serves to avoid this, it is not my best recommendation, but after almost 3 weeks trying mathematical calculations, random explanations, this was the only one that worked regardless of the amount of objects in the scrolling frame.