How do I get a key's name in a table

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

So, let’s imagine I have this table right?

image

and I loop through it in a module with an in pairs loop.

however, I need to get the name “Rounds” somehow.

  1. What is the issue? Include screenshots / videos if possible!

I do not know how to do that. v simply gives me its value (1), and table[i] doesn’t work either. How should I work around this?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Mostly devforum, because I don’t think that the Docs will have anything relevant to my issue.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I won’t, I promise :slight_smile:

1 Like

You mean your trying to get the key? Because in your case “Rounds” is a key in a table

1 Like

Yes. Thank you. I might try to research it now, because I didn’t know its name lol

2 Likes

:sob:

I cannot believe I missed this.

Since this was a pairs loop and not an ipairs one, I could’ve used i. The index.

It was this easy all along. I feel stupid.

Thanks to @astraIboy for (trying to) help!

1 Like

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