Help how to make autoscroll in ScrollingFrame so that it scrolls to the size of the gui that is in the ScrollingFrame
If you have something like a UIListLayout or UIGridLayout, you can use the following code.
local layout = -- Reference your UI layout object local scrollingFrame = -- Reference your scrolling frame local function setSize() local contentSize = layout.AbsoluteContentSize scrollingFrame.CanvasSize = Vector2.new(contentSize.X, contentSize.Y) end setSize() -- Update the size as soon as the game starts so if there is already something in it, it will be displayed correctly. layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function() setSize() end)
This code uses the GetPropertyChangedSignal event to detect when the total size of the content being manipulated by the UI layout object is changed. This means that if something new gets added to the scrolling frame, it will automatically update.