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:
local Value = 0 local WorkspaceChildren = workspace:GetChildren() for i = 1, #WorkspaceChildren do local Child = WorkspaceChildren[i] Value = Value + 1 Child.Name = Value 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)
for i = 1, 10 do print(i) 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:
local Fruits = {"Apple", "Banana", "Orange"} 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:
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.