How can I go about grabbing the last values of a nested table?

I have this nested table here, how can I go about grabbing the last values of the nested table?

	["Stats"] = {
		["Money"] = "0";
		["Multi"] = "1";

		["Rebirth"] = "0";
		["Ultra Rebirth"] = "0";
	};
	
	["leaderstats"] = {
		["Level"] = "1";
	};
	
	["Miscellaneous"] = {
		["TutorialDone"] = false;
		["TimePlayed"] = 0
	}

the expected output:

["Money"] = "0";
["Multi"] = "1";
["Rebirth"] = "0";
["Ultra Rebirth"] = "0";
["Level"] = "1";
["TutorialDone"] = false;
["TimePlayed"] = 0

You can just loop through it, unfortunately you cannot guarantee the order due to it being a dictionary.

local someTable = {	["Stats"] = {
	["Money"] = "0";
	["Multi"] = "1";

	["Rebirth"] = "0";
	["Ultra Rebirth"] = "0";
};

["leaderstats"] = {
	["Level"] = "1";
};

["Miscellaneous"] = {
	["TutorialDone"] = false;
	["TimePlayed"] = 0
}
}

local newTable = {}

for i, innerTable in pairs(someTable) do
	for key,value in pairs(innerTable) do
		newTable[key] = value
	end
end

print(newTable)

image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.