for loops are numeric loops, but ipairs loop is a loop which loop through table of instances
example
for number = 1, 5, 1 do
print(number)
end
output:
1
2
3
4
5
the first number in there is the minimum value, 1
second number is 5, which is the maximum value
you can think them as start and end
the third number is how many number skips per loop, default is 1, if you put something that is like for number = 1, 5, 6 do
it will not run, since it does not meet the requirement, formula is
(secondNumber - firstNumber) / thirdNumber = math.floor(howManyTimeItLoops)
for i, v in pairs / ipairs loop are instances loop like loop through an table of instances, well GetChildren returns a pair of table of the instance children, so we can do
for number, theChildrenThatIsDefinedOnLoop in ipairs(game.Workspace:GetChildren()) do
print(theChildrenThatIsDefinedOnLoop.Name .." is the ".. number .."st/nd/rd/th children"
end
it basically scans through children and print the currently scanning/ defined children value
if you dont understand, i think i will explain more since I HAVE HOMEWORK SO im in a candy rush moment byebye
2 comments
oh by the way, pairs is randomly choosen children, so if you run my script (the ipairs part) with pairs, you will not get the same result everytime you run because its random (don't ask me why, i didn't make it)
i have a hard time learning this too, but i hope i explained well because my logic isnt same with the other peoples (i think that's why i have a hard time learning this)