Stacking up frames with script

Hello developers! Today i tried to stack up frames with a script ( because I made car shop and when someone buys it there shouldn’t be any gaps of nothing between car’s frames)

i used this script:

local startx, starty = 0.039, 0.005
local incx, incy = 0.039, 0.093
local countx = 3
local maxx = startx + countx + incx
local posx, posy = startx, starty

game.ReplicatedStorage:WaitForChild("ChangeTitleVisible").OnClientEvent:Connect(function(value)
	script.Parent.NoCars.Visible = value
end)

game.ReplicatedStorage:WaitForChild("AddCar").OnClientEvent:Connect(function(CarName)
	local car = script.Parent:FindFirstChild(CarName)
	if car then
		car.Visible = true
		car.Position = UDim2.fromScale(posx, posy)
		posx = posx + incx
		if posx >= maxx then
			posx = startx
			posy = posy + incy
		end
	end
end)

but this makes frames position them one to each other and not one below other. can somebody help me make them one below each other thanks.

sorry for bad english.
have a good day :smiley:

3 Likes

UiListLayouts would be useful here

1 Like

As I understand it, you want the frames to be under each other without a gap.

I would just use UIListLayout for this situation.

2 Likes