UIListLayout Items don't go in order

I made a custom donation leaderboard script but the items don’t go in order.

image
I have even tried to set up the layour oder, here’s the script:

for Price, ProductId in pairs(Products) do
	local NewTemplate = Template:Clone()
	NewTemplate.LayoutOrder = Price
	NewTemplate.Parent = ScrollingFrame
	NewTemplate.Visible = true
	NewTemplate.Price.Text = tostring(Price)
	local BuyButton = NewTemplate.BuyButton
	
	BuyButton.MouseEnter:Connect(function()
		local tween = ts:Create(NewTemplate, TweenInfo.new(0.35), {BackgroundColor3 = Color3.fromRGB(132, 132, 132)}):Play()
	end)
	
	BuyButton.MouseLeave:Connect(function()
		local tween = ts:Create(NewTemplate, TweenInfo.new(0.35), {BackgroundColor3 = Color3.fromRGB(70, 70, 70)}):Play()
	end)
	
	BuyButton.MouseButton1Down:Connect(function()
		local tween = ts:Create(NewTemplate, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(176, 176, 176)}):Play()
	end)
	
	BuyButton.MouseButton1Up:Connect(function()
		local tween = ts:Create(NewTemplate, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(132, 132, 132)}):Play()
		mps:PromptProductPurchase(Player, ProductId)
	end)
end

Layout Order


Use the layout order property of any UI object to give it a priority.

Example:

NewTemplate.LayoutOrder = Price


The reason I place Price as its Layout Order is that the Price already tells that it’s bigger or smaller than the other objects.

doesn’t work, still same issue.

Whats the SortOrder?
image

The sort order is LayOutOrder.

Could you give me a screenshot of NewTemplate’s properties?

image

Go into play test and check what all the Layout orders are for each template.

All of them are corresponding to the price that they are given.

local module = {
	DevProducts = {
		[5] = 1273878405, -- [Price of the Product] = ProductId
		[10] = 1273879382,
		[50] = 1273880071,
		[100] = 1273879381,
	}
}

return module

I’ve tested the numbers on layout orders and seems to be working so I have honestly no idea what could be your problem…

1 Like

Use ipairs instead of pairs. ipairs will always have the same index.

I’m not sure if this will work with ipairs or not.