I don't know how to return the name of a table from a table

Hello, I’m trying to get the name of any table in my dataTemplate. I don’t know how to do this. I’ve searched the internet and nothing is helpful so far.

local dataTemplate = {
	["Boosts"] = {
		["Red"] = 0;
		["Blue"] = 0;
		["Green"] = 0;
		["Pink"] = 0;
		["Purple"] = 0;
		["Golden"] = 0;
	};

	["CharacterPositions"] = {
		["X"] = 0;
		["Y"] = 0;
		["Z"] = 0;
	};

	["Currency"] = {
		["Candy"] = 0;
		["Redeemed"] = 0;
		["Time"] = 0;
	};

	["GamePasses"] = {
		["X2Time"] = false;
		["X5Time"] = false;
		["X10Time"] = false;
		["Vip"] = false;
	};

	["Misc"] = {
		["Halloween2024"] = false;
		["TransferredData"] = false;
		["ReceivedVipPerks"] = false;
	};

	["CodesRedeemed"] = {};

	["UGCsPurchased"] = {};
}

What I’m trying to achieve:

	for _, dataType in dataTemplate do
		-- I'm trying to return the name of the data type ("Boosts", "Currency", whatever); how do I do this?
	end

instead of _ use a var since that will be the name of the data type

1 Like

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