"myIndex" is the place in the table (a number) where you insert something
so if you have randomtable = {}
randomtable[6] = 4
then the 6th slot in the table will have the value 4
while in table.insert() the first argument is the tablename, and the second argument is the value
so table.insert(randomtable, 8) will give the first available slot (in this case the first) the value 8
if you would now do randomtable[1] it will return you 8
if you would do randomtable[6] it will give you 4
table.insert(tChars,string.sub(mystring,i,i))
That will insert the result of string.sub(mystring,i,i) in the first available table slot in the tChars table.
The result of string.sub(mystring,i,i) is of course dependent on i and the string, but i trust you already knew that..
for instance
local mystring="hello world!"
local tChars={}
for i=1,#mystring do
table.insert(tChars,string.sub(mystring,i,i))
end
That will make i go from 1 to #mystring (the number of characters in the string, in this case 12).
if i arrived at the point at which it is for instance 7, it will do the following
table.insert(tChars,string.sub(mystring,7,7))
so it inserts a value into the first available slot in the tChars table, and that value is the 7th character of mystring, or w
if you would do string.sub(mystring,7,9) it would give you the 7th till the 9th character of mystring, or wor
if you wold do string.sub(mystring,7) it would give you the 7th till the last character of mystring, or world!