It iterates over a table.
i is the position of the element, and v is the element itself. They don't need to actually be named i and v.
Inside of the parentheses next to pairs, put the table. When you're new to scripting, this will usually be some form of GetChildren, because applied coding is a good way to learn.
If you ever see 'ipairs', it's basically the same as 'pairs', but with a few more limitations that would take me extra time to explain. In theory, it is supposed to be able to run faster because it is doing less, but in practice it tends to run only as fast as 'pairs', and occasionally slower. This is a glitch, it's not supposed to actually be so slow.
Having said that, I hope it will be no surprise when I say you needn't concern yourself with the difference between the two, just use 'pairs' and you'll be all good.
|