So if i go print(i.." "..v) the i is 1 and the v is whatever is in the table, so why does it print out the v when i go print(table[i])
✓ ANSWER ACCEPTED
Why does it print the 'v' when i tell it to print 'i' ?
1 answer
✓ Accepted answer
It might be a little clearer if we rewrite
for i,v in pairs(table) do
print(table[i])
end
as
for index, value in pairs(table) do
print(table[index])
end
The i or index here refers to the index in table table of value v or value.
Basically, table[i] == v returns true because i is defined that way.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Maybe, if you showed the code we'll know why
We will need you to post the script for us to understand what is wrong.
There is no script to post, i'm just asking on how tables work with the in pairs.