I was wondering how to get the value two or more numbers that are the same in a table
Indexing is basically grabbing values in the table.
local Table = {1,2,3} local Index = math.random(1,3) print("Selected number - "..Table[Index])
In the code above we have a table with three values, 1, 2, and 3. We have a variable which has a randomized value of 1 through 3.
We print the line the array is in using the Index variable.
Example:
Table 1 - 1 2 - 2 3 - 3 The left number represents the line the specific value is in. The right number represents the value of the line its on.
So above is an array which has the following:
The 1st line has the value of 1. The 2nd line has the value of 2. The 3rd line has the value of 3.
We get a random line number using math.random(1,3).
We get 2.
We search for the 2nd line in the table. It's value is 2!
We print that and in the output it should read "Selected number - 2"