Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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.

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. BlackJPI 2658 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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
Ad

Answer this question