Roblox > Scripting Lessons >

Lesson 6: For Loops

For Loops are very similar to while loops. The for loop allows you to easily repeat one action a certin number of times. Here is the format of the for loop:

for (var=1,5) do
-- Insert actions here

I believe the best way to explain the this loop would be to compare it to a while loop. If the previous for loop was a while loop this is what it would look like:

var = 1 -- This is the first part of the condition

while (var =< 5) do -- The 5 is taken from the second part of the for loop
-- Insert actions here
var = var + 1

When you think of for loops I think it is best for you to just think of it as a while loop in that format. If there is anything about this lesson you didn't get please PM me or Post on the Forums.

<- Previous Lesson  Next Lesson ->
Updated on Apr 23, 2010 by Ajedi32 (Version 6)
comments powered by Disqus