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

How would I get the name of a table object?

Say I have this script...

local Passes = {["DjDoor"] = 4846905
			}

How would I be able to to get the name "DjDoor" if I had the ID 4846905? Would I have to make ["DjDoor"] an array and add another string like this...?

local Passes = {["DjDoor"] = {4846905, "DjDoor"}
			}

Or is there another way to obtain it?

1 answer

✓ Accepted answer

Just use a key-value for loop:


for key, value in pairs(Passes) do
	if value == 4846905 then
		print(key, value) -- You can access both
	end
end

2 comments

1

Thanks, for some reason I thought that would have returned the index number.

0

No worries, we all get those brain dead moments lol

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