Why is the inventory arranged this way?

You can write your topic however you want, but you need to answer these questions:
This isn`t much of a problem but the layout makes it hard to understand where most items are.
the inventory used GUIs stored in the server and coped and changed to suit that item but its always arranged into this:

And this is the tables of infos arrangement:

image

Why are the items not near the other items near the others in the table?
Script that makes the guis:

for key,val in next,Info do
	print(key)
	if val.Tool == false then
		if val.Eat == true then
			local NewFrame = game.ReplicatedStorage.GUI["EmptyFrame(Eat)"]:Clone()
			NewFrame.Parent = script.Parent
			NewFrame.Name = key
			NewFrame.Image.Image = val.ImageInfo
			NewFrame.Stats.Item.Value = key
			NewFrame.Info.Text = val.Info
		else
			local NewFrame = game.ReplicatedStorage.GUI["EmptyFrame"]:Clone()
			NewFrame.Parent = script.Parent
			NewFrame.Name = key
			NewFrame.Image.Image = val.ImageInfo
			NewFrame.Stats.Item.Value = key
			NewFrame.Info.Text = val.Info
		end
	end
end
1 Like

Items in dictionaries aren’t necessarily in the order you declared them in

2 Likes

Is there away to change how its arranged?

1 Like

Yes, convert the dictionary into an array and iterate over it using the ipairs() iterator function.

I`ve change the first line but I get the exact same result can you elaborate
new line:

for key,val in pairs (Info) do

The simple approach is to get all the keys in your dictionary table, put them into an array table, and then sort them with table.sort().
After you done that, simply iterate through that array to arrange your dictionary.

-- get keys in a dictionary
local keys={}
for x,y in pairs(Info) do
    table.insert(keys, x)
end

table.sort(keys) -- arrange the keys

-- iterate like normal
for x in ipairs(keys) do
    val=Info[x]
    -- your code

Oh I think theres some confusion in how the tables arranged and I dont this this method is compatible with it is this true? I can`t read the information.

Info.BookB = {ImageInfo = "rbxassetid://9304238814",
	Eat = false,
	Tool = false,
	Info = "An Empty Book (Blue).",
	CanCraft = false}

I`ve fixed the problem I added some more information to the table about the GUI and it clean up so much (info about UI order)