How do i make a automatic scrolling frame

  1. What do you want to achieve? Keep it simple and clear!
    im trying to make a scrolling frame that only can scroll when the items go “off” the frame
  2. What is the issue? Include screenshots / videos if possible!
    im trying to do it for so long and i just don’t know how to make it so that it fits perfectly
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i looked in dev forum but didn’t find anything that worked
    also tried using UIGridLayout and UIListLayout which didn’t work

code that manages the frame:

local temp = script.template:Clone()
		temp.Parent = script.Parent.inventory.items
		temp.Position = temp.Position+UDim2.new(posX,0,posY,0)
		temp.Visible = false
		table.insert(toEnable,temp)
		posX = temp.Position.X.Scale+temp.Size.X.Scale
		if temp.Position.X.Scale > 0.9 then
			--print('a')
			posY = temp.Position.Y.Scale+temp.Size.Y.Scale
			posX = 0
			temp.Position = script.template.Position+UDim2.new(posX,0,posY,0)
		end
		script.Parent.inventory.items.CanvasSize = UDim2.new(0,0,0,temp.AbsolutePosition.Y)
		for _,v in pairs(temp.item_viewport:GetDescendants()) do
			num = num + 1
		end
		for _,v in pairs(temp.item_viewport:GetDescendants()) do
			spawn(function()
				local succ, fail = pcall(function()
					game:GetService("ContentProvider"):PreloadAsync({v})
					l = l + 1
				end)
				if fail then warn(fail) end
			end)

		end

any help would be appreciated

4 Likes

I would tell to search the devforum well next time for the sake of no one
Here check this link:

no i meant to like increase the ScrollingFrame’s CanvasSize to fit everything not move everything, idk if im just dumb or i just explain that way

If I understood what you mean, there is an automatic scaling property in a scrollbar gui
You can set it to X or Y or both. But remember to set the canvas size to 0,0,0,0 if you will use this.

scrolling frames already have this property, they automatically adjust their size according to the size of the contents

https://developer.roblox.com/en-us/api-reference/property/GuiObject/AutomaticSize

that doesnt work well, it just resizes the ScrollingFrame instead of the ScrollingFrame’s CanvasSize
here ill show u what i mean, in studio it is perfectly aligned with the other frame but when the items appear, it just resizes it instead of resizing the CanvasSize


and no, i can’t scroll, it just works like it has CanvasSize 0,0,0,0

nevermind apparentely now i set AutomaticSize to none and AutomaticCanvasSize to XY and now it works perfectly even tho when i tried it some days ago without AutomaticSize it was just making the sword icons’ Y so long
im having a lot of wild and troll moments in this app thing idk if it’s just me who’s dumb or other bugs or idk

4 Likes

in ordere to have them frames inside always the same size and shape you need to use a size constraint on the frame(using the plugin) and then parent that size constraint to the Ui grid layout you are using to order the frames and this will apply it to all the frames