How would I get the index of a table from the table

image
I have weighted rng return a table however the table does not give me what the item index is so how would I get the item index aka [“Apple”] from the table.

Nested tables (tables in tables) should only be used when you have more than 1 value that you’d like to store under that key. You can store them in tables like that, however it’s pretty inefficient and easy to just do

Items["Apple"] = 1000

However, if you want to get the weight index from that table, you can, and it’s pretty simple. All you have to do is:

print(Items["Apple"]["Weight"])
> 1000

When you index the first square bracket, i.e. the Items[“Apple”] the program returns the table, meaning you’re basically just indexing from another table.

actually I could probably just store the key inside the table nevermind