Script is printing tables in a numerical order, and some tables are missing

I’m creating a script in the player that requests data to the server, and the server sends tables, i’m currently working with this example:

local St = {["GoodPerson"] = {
	[29999999999] = {
		["A"] = 1;
		["B"] = 1;
	};
	[1] = {
		["A"] = 1;
		["B"] = 1;
	};
	[3] = {
		["A"] = 1;
		["B"] = 1;
	};
	[2] = {
		["A"] = 1;
		["B"] = 1;
	};
	};
}

So, 29999999999, 1, 3 and 2 are the tables that are going to be printed, and now the problem is that this is not being printed as expected:

1
2
3

For any reason, this is printing in a numerical order, and numbers that are skipping other numbers, like 1 and 3, 3 is not being printed. I find very strange, here is the LocalScript:

local RepStorage = game:GetService("ReplicatedStorage")
local GetSD = RepStorage:FindFirstChild("GetShopData")

print("Getting a table...")
wait(5)
local newPart = GetSD:InvokeServer()

local Stu = unpack(newPart)

for Yes, Table in pairs(Stu) do
	print(Yes)
    for TableName, a in pairs(Table) do
        print(TableName)    
    end
end

And here is the ServerScript:

local RepStorage = game:GetService("ReplicatedStorage")
local GetSD = RepStorage:FindFirstChild("GetShopData")
local Error = 0

local St = {["GoodPerson"] = {
	[29999999999] = {
		["A"] = 1;
		["B"] = 1;
	};
	[1] = {
		["A"] = 1;
		["B"] = 1;
	};
	[3] = {
		["A"] = 1;
		["B"] = 1;
	};
	[2] = {
		["A"] = 1;
		["B"] = 1;
	};
	};
}

local function Boomer(Player)
	local PackedST = table.pack(St)
	return PackedST
end

GetSD.OnServerInvoke = Boomer

I searched in the developer hub for some solutions, but i didn’t find something useful. Thanks for reading.

Sorry, but I wasn’t able to replicate your issue. Are you sure there isn’t something different between the code you’re running and what you posted?

This section of your code

for Yes, Table in pairs(Stu) do
    print(Yes)
    for TableName, a in pairs(Table) do
        print(TableName)    
    end
end

Gave the following output

GoodPerson
1
2
29999999999
3

This is happening because these are not numerical indices, they are keys. Story short: Keys aren’t organized. They don’t have an exact organazation. Thay aren’t ordered alphabatically, nor chronologically. If you put [1] then [2], it won’t print 1 then 2, the order will be different.

The code i gave is the same, i have changed some variable names only:

local RepStorage = game:GetService("ReplicatedStorage")
local GetSD = RepStorage:FindFirstChild("GetShopData")

print("Getting a table...")
wait(5)
local newPart = GetSD:InvokeServer()

local StupidTable = unpack(newPart)

for Yes, Table in pairs(StupidTable) do
	print(Yes)
    for TableName, a in pairs(Table) do
        print(TableName)    
    end
end
local RepStorage = game:GetService("ReplicatedStorage")
local GetSD = RepStorage:FindFirstChild("GetShopData")
local Error = 0

local StupidTable = {["GoodPerson"] = {
	[29999999999] = {
		["A"] = 1;
		["B"] = 1;
	};
	[1] = {
		["A"] = 1;
		["B"] = 1;
	};
	[3] = {
		["A"] = 1;
		["B"] = 1;
	};
	[2] = {
		["A"] = 1;
		["B"] = 1;
	};
	};
}

local function Boomer(Player)
	local PackedST = table.pack(StupidTable)
	return PackedST
end

GetSD.OnServerInvoke = Boomer

I have changed those variables in a more friendly one


@starmaq

For any reason, it’s printing in a numerical order, if you need a screenshot, here it is:

However, do you think there’s any solution to this?