So basically I have cam Across these two methods and said... "Hey could these two methods of looping be alike" but now I want someone to actually tell me if
For i,v in pairs(object:GetChildren()) do
and for i = 1, #OfChildren
do are alike.
The for i,v in pairs() do
function gets everything in a table or item. v is everything inside that array or item. i is the number of each item. So suppose that you wanted to print all of the items. So you would do print(tostring(v))
. Or let's say warn(tostring(v))
. Same thing with i.
The for i = 1, 10 do
function stores the variable i as a starting value (left) and an ending value (right). 1 is our starting value, while 10 is our ending value. Like in your for loop, you can do for i = 1, #EndingValue do
. This can be used to move parts, or even rotating parts.
Hope this is helpful. If you need more help, visit the developer wiki on both types of for loops.