Is there a better way to do this?

Provide an overview of:

  • What does the code do and what are you not satisfied with?
    The code refreshes the customized inventory, since sometimes it goes like this
    Screen Shot 2023-01-28 at 5.38.28 PM

  • What potential improvements have you considered?
    Not really much the code works fine yeah but my head tells me theres another cleaner way to do it

  • How (specifically) do you want to improve the code?
    I want to make it look more neat, I want to learn more, get tips on how to make the code look more reasonable

util.refresh = function()
	local values = {}
	for i = 1, 3, 1 do
		for _, v in pairs(toolbar:GetChildren()) do
			if v.Name == nameframe then
				local tnv = v.ToolNumber.Value
				if tnv == 1 then
					v.Parent = nil
					values[v.ToolNumber.Value] = v
				else
					if values[v.ToolNumber.Value-1] then
						v.Parent = nil
						values[v.ToolNumber.Value] = v
					end
				end
			end
		end
	end
	for _, v in pairs(values) do
		v.Parent = toolbar
	end
	
end

That’s the code I use, all I do is require(util).refresh() then it will organize my tools based on the number.

From
Screen Shot 2023-01-28 at 5.41.40 PM

To this
Screen Shot 2023-01-28 at 5.42.02 PM

Like I said, there’s no bugs or nothing wrong, just asking for any other way?

Maybe UIListLayout by alphabetical order and name the UI’s like: Number..Name?

i use ui grid layout or ui list layout i think… do they automatically arrange by alphabet ?

Yeah, you can set a property
30limittttttttttttttttttttt

You would use UIListLayout and set the SortOrder property to LayoutOrder if it’s not already on that by default. Then you would just set the LayoutOrder of the frame to the order you want it displayed.