Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I script an adaptable scroll frame?

So I plan on having a scroll frame that inside has multiple buttons laid out using UIGrid layout or UIList layout, and every time you collect an item it adds to the inventory. But eventually the entire frame would be taking up but the scrollbar has met it's maximum scroll distance, how would players be able to reach to the bottom?

I have noticed that there is a property called CanvasSize, but how would I need to change the size of it so that any amount of items can be included inside, potentially a HUGE amount. What kind of fancy maths would I need to do?

2 comments

0

make a search bar using string.match()

0

I mean, you could make a UI that doesn't work off scrolling but off pressing a button to go to the next page of items... Like a little arrow key at the bottom of the UI that just tweens the next frame with the list of buttons.

1 answer

✓ Accepted answer

Fairly easy, actually. A UIListLayout has an AbsoluteContentSize that you can use for your canvas size. Consider the following:

UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
	local size = UIListLayout.AbsoluteContentSize
	ScrollingFrame.CanvasSize = UDim2.new(0,size.X,0,size.Y)
end)

This will update the CanvasSize every time the content changes.

If I helped, be sure to upvote/accept!

1 comment

0

Lovely stuff! Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.