Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get a table's name which is in another one?

I'm trying to get the table name with this script but it doesn't work...

local FirstTable = {SecondTable = {Hello = "Hello", Bye = Goodbye}, Lol = "Laughing Out Loud"}
print(FirstTable[1])

It prints the table itself, not the "Name" of the table, I would like to print that: SecondTable

Using tostring(FirstTable[1]) doesn't work too. Well I tried everything, anyone have a solution?

4 comments

0

I am about to be right back then I will answer it

0

ok

0

Why do you want to get the name of the table?

0

Well, because it's for a model, made of multiples things, and the model is in the ServerStorage, if a script read the table and find eg. "NormalModel" it will clone it from the SS.

1 answer

✓ Accepted answer

The only way I can think of doing this is using the pairs function, like this:

for k, v in pairs(FirstTable) do
	print(k)
	break
end

To be honest, I wouldn't be surprised if there's a better way of doing this.

This discussion is preserved as it was. New answers, comments, and votes are closed.