How do I get the position of a table?
Now, I'll explain here. A while ago, I figured out how to make it so that it chooses a random item inside a table, but I want to know what place it is in. Still confused? Here's some code that I made.
1 | local testing = { "Hello world!" , "Hi!" , "Greetings!" } |
2 | local r = testing [ math.random( 1 , #testing) ] |
Now say this would pick the second item in the table ("Hi!"). Now it would print what the string says, but I want it to print on what place the table is on. What I mean by that is in that example, it is on the 2nd item in the table. Basically, I want to figure out how to get the place the random item picker is on.