ListOrder not working correctly

How would I go about making the “Speed Upgrade 1” appear before the “Speed Upgrade 2” button

Sometimes it appears first, sometimes not.

image

Set LayoutOrder to where you want it to be, for example Speed Upgrade 1 would have a LayoutOrder of 1, and Speed Upgrade 2 would have a LayoutOrder of 2.

1 Like

Thanks for replying, I have set the LayoutOrder to the index
image

And also set it in the UIList
image

However its still not displaying properly:
image

Can you share all of your code please?

1 Like

Its quite a handful, but here:

local function LoadSkills(Upgrade)
	
	local Upgrades = Upgrade:GetChildren()

	script.Parent.SkillTree.SkillDisplay.SkillDisplay:ClearAllChildren()
	
	if MouseEvent then
		MouseEvent:Disconnect()
		if script.Parent:FindFirstChild('MouseKey') then
			 script.Parent.MouseKey:Destroy() 
		end
	end
	local UIListLayout = Instance.new("UIListLayout")

	--Properties:

	UIListLayout.Parent = script.Parent.SkillTree.SkillDisplay.SkillDisplay
	UIListLayout.FillDirection = Enum.FillDirection.Horizontal
	UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
	UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Center
	UIListLayout.Padding = UDim.new(0.00100000005, 0)

	local Poop = Instance.new("Frame")
	local CharmDescription = Instance.new("TextLabel")
	local CharmAmount = Instance.new("TextLabel")


	Poop.Name = "MouseKey"
	Poop.BackgroundColor3 = Color3.fromRGB(15, 15, 15)
	Poop.BorderColor3 = Color3.fromRGB(40, 40, 40)
	Poop.BorderSizePixel = 2
	Poop.Position = UDim2.new(0.0888776332, 0, 0.293371975, 0)
	Poop.Size = UDim2.new(0.192731068, 0, 0.248959467, 0)
	Poop.ZIndex = 1000000008
	Poop.Parent = script.Parent
	Poop.Visible = false

	CharmDescription.Name = "CharmDescription"
	CharmDescription.Parent = Poop
	CharmDescription.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	CharmDescription.BackgroundTransparency = 1.000
	CharmDescription.Position = UDim2.new(0.0395984799, 0, 0.111329161, 0)
	CharmDescription.Size = UDim2.new(0.920802891, 0, 0.543676734, 0)
	CharmDescription.ZIndex = 1000000008
	CharmDescription.Font = Enum.Font.GothamBold
	CharmDescription.Text = ""
	CharmDescription.TextColor3 = Color3.fromRGB(255, 255, 255)
	CharmDescription.TextScaled = true
	CharmDescription.TextSize = 100.000
	CharmDescription.TextStrokeTransparency = 0.000
	CharmDescription.TextWrapped = true
	CharmDescription.TextYAlignment = Enum.TextYAlignment.Top
	CharmDescription.RichText = true

	CharmAmount.Name = "CharmAmount"
	CharmAmount.Parent = Poop
	CharmAmount.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	CharmAmount.BackgroundTransparency = 1.000
	CharmAmount.Position = UDim2.new(0.0395984799, 0, 0.857643545, 0)
	CharmAmount.Size = UDim2.new(0.920802891, 0, 0.138006166, 0)
	CharmAmount.ZIndex = 1000000008
	CharmAmount.Font = Enum.Font.GothamBold
	CharmAmount.Text = "Cost:"
	CharmAmount.TextColor3 = Color3.fromRGB(255, 255, 255)
	CharmAmount.TextScaled = true
	CharmAmount.TextSize = 100.000
	CharmAmount.TextStrokeTransparency = 0.000
	CharmAmount.TextWrapped = true
	CharmAmount.TextYAlignment = Enum.TextYAlignment.Top
	
	

	MouseEvent = Mouse.Move:Connect(function()
		Poop.Position = UDim2.new(0,Mouse.X,0,Mouse.Y + 30)
	end)
	
	
	


	for Index,UpgradeObject in pairs(Upgrades) do
		
	local Upgrade = Instance.new("TextButton")
	local SkillDisplay = Instance.new("Frame")

		Upgrade.Name = Index
		Upgrade.LayoutOrder = Index
	Upgrade.Parent =script.Parent.SkillTree.SkillDisplay.SkillDisplay
		Upgrade.BackgroundColor3 = Color3.fromRGB(24, 24, 24)
		
		if Player.Charms.Value >= UpgradeObject.Price.Value then
			Upgrade.BorderColor3 = Color3.fromRGB(9, 26, 2)
		else if game.ReplicatedStorage.GameRemotes.Upgrades.CheckIfOwnedUpgrade:InvokeServer(UpgradeObject) == true then
				Upgrade.BorderColor3 = Color3.fromRGB(91, 255, 20)
			else if Index == 1 then
					Upgrade.BorderColor3 = Color3.fromRGB(33, 32, 32)
				else
					Upgrade.BorderColor3 = Color3.fromRGB(33, 32, 32)
					Upgrade.TextTransparency = 0.3
					Upgrade.BackgroundTransparency = 0.3
				end

			end

		end
		
		if UpgradeObject.RequiresSkill.Value then
			if game.ReplicatedStorage.GameRemotes.Upgrades.CheckIfOwnedUpgrade:InvokeServer(UpgradeObject.RequiresSkill.Value) then
				Upgrade.TextTransparency = 0.6
				Upgrade.BackgroundTransparency = 0.6
			end
		end
	Upgrade.BorderColor3 = Color3.fromRGB(33, 32, 32)
	Upgrade.BorderSizePixel = 2
	Upgrade.Position = UDim2.new(0.000616657548, 0, 0.243251935, 0)
	Upgrade.Size = UDim2.new(0.00623057969, 0, 0.500577569, 0)
	Upgrade.ZIndex = 1000000002
	Upgrade.Font = Enum.Font.GothamBold
		Upgrade.Text = UpgradeObject.UpgradeName.Value
	Upgrade.TextColor3 = Color3.fromRGB(255, 255, 255)
	Upgrade.TextScaled = true
	Upgrade.TextSize = 14.000
		Upgrade.TextWrapped = true

	SkillDisplay.Name =  Index
	SkillDisplay.Parent = Upgrade
	SkillDisplay.BackgroundColor3 = Color3.fromRGB(36, 36, 36)
	SkillDisplay.BorderColor3 = Color3.fromRGB(40, 40, 40)
	SkillDisplay.BorderSizePixel = 0
	SkillDisplay.Position = UDim2.new(1.00408614, 0, 0.401267707, 0)
	SkillDisplay.Size = UDim2.new(0.323480546, 0, 0.242582262, 0)
	SkillDisplay.ZIndex = 999999999
		
		
		Upgrade.MouseEnter:Connect(function()
			Poop.Visible = true
			if UpgradeObject.RequiresSkill.Value then
				CharmDescription.Text = UpgradeObject.UpgradeDescription.Value.."/n Requires Skill: "..UpgradeObject.RequiresSkill.Value.Name
			else
				CharmDescription.Text = UpgradeObject.UpgradeDescription.Value

			end
			
			CharmAmount.Text = "Cost: "..UpgradeObject.Price.Value.." Charms"
		end)
		
		
		
		
		Upgrade.MouseLeave:Connect(function()
			Poop.Visible = false
		end)
		
		Upgrade.MouseButton1Click:Connect(function()
			local BuyStatus
		end)
		
		
		
		if Upgrades[Index + 1] == nil then
			SkillDisplay:Destroy()
		end
		wait()
	end


end