Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

There are different type of for loops, What do they do?

I saw a simple for loop which an example would be this:

for i = 1, 3 do
	print(i)
end

Also a more complex for loop that I found from the wiki:

local Players = game:GetService("Players")
 
function onPlayerAdded(player)
     print(player.Name .. " has entered the game")
end
 
--When a player joins, call the onPlayerAdded function
Players.PlayerAdded:connect(onPlayerAdded)
 
--Call onPlayerAdded for each player already in the game
for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end

I don't really know what these do.

1 comment

0

The wiki has a super indepth page devoted just to loops (make sure to check the See Also links as well): http://wiki.roblox.com/index.php?title=Loops.

1 answer

✓ Accepted answer

Loops This will take you to the ROBLOX Wiki, which explains all the basics about loops on ROBLOX,

For Loops This will take you to a more specific wiki about just for loops, and how to use them effectively and how they function.

  • NinjoOnline

This discussion is preserved as it was. New answers, comments, and votes are closed.