What does it mean?
I know exactly what it does but I have no idea what it actually means; what does i mean? Does it stand for something?
Example:
01 | local Value = 0 |
02 | local WorkspaceChildren = workspace:GetChildren() |
03 |
04 | for i = 1 , #WorkspaceChildren do |
05 |
06 | local Child = WorkspaceChildren [ i ] |
07 | Value = Value + 1 |
08 |
09 | Child.Name = Value |
10 |
11 | end |
The code sets all the children of workspace to a number (which goes up in 1 every child).
The for
loop has a beginning and an end number. For example (no pun intended)
1 | for i = 1 , 10 do |
2 | print (i) |
3 | end -- Code made by Qub_lex |
It would loop through all numbers from 1 to 10 and print all of them.
The #
means length or how many items there are in a table.
For example:
1 | local Fruits = { "Apple" , "Banana" , "Orange" } |
2 | print (#Fruits) |
Would return 3
, because there are three items inside the table.
Edit: Just realised I didn't even answer your question. i
is a placeholder variable that stands for "Integer" or sometimes "Index".
i
would be the current number the loop is at.
If you ran this in the command bar:
1 | for i = 1 , 10 do print (i) end |
The output would be counting up, as it keeps printing the current number (i)
as the loop continued.