How can I automatically position a button under each other with a script?

So basically in my script i have a table variable and I have another code that clones a button and places it in the scrollingframe, but the problem is they’re all in the same position, how do I create it so it all goes under each other, I’ve looked up tutorials but it didn’t really help me out.

Current code:

local count = 0

for i, v in pairs(tools:GetChildren()) do
	table.insert(toollist, v)
	count = count + 1
	local button = testButton:Clone()
	button.Name = "ApeButton"
	button.Text = v.Name
	button.Parent = script.Parent.MainFrame.ScrollingFrame
	--button.Position =, 0,0. + 075, 0)
	apesize = button.AbsoluteSize.Y
	local csize = (count * apesize)
	script.Parent.MainFrame.ScrollingFrame.CanvasSize =, 0, 0, csize)

Everything here works fine, it’s just that I need to know how to position each button under each other so it’s alined nicely, please help me down below

I think what you are looking for is UI List Layout.

1 Like

You can use what @Helyras suggested, or you can do this:

button.Position = Udim2.fromOffset(0, (count - 1) * apesize)
1 Like

I’ve gotten this error, I can’t really understand UI list layouts as I never scripted them, this is my first time:


Appreciate it but I learn everything on my own so I barely know all the names of stuff, thanks anyway

Did you set the position before the line where apesize is assigned? It needs to be set after that line.

1 Like

Oh damn it worked now!

Appreciate it my guy, I gotta read more about these stuff, thanks