Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I get the name of a table object?

Asked by 5 years ago

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

Log in to vote
2
Answered by 5 years ago

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
1
Thanks, for some reason I thought that would have returned the index number. climethestair 1663 — 5y
0
No worries, we all get those brain dead moments lol ScrewDeath 153 — 5y
Ad

Answer this question