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

Can someone help me?

I'm trying somethings out and I've come across loops. I don't understand it and would really appriciate a explaination. Try not to give me a link to a video or something.

5 comments

0

(this question does not belong on this site) http://wiki.roblox.com/index.php?title=Conditional_statement

0

It's a question about scripts and I asked to not be linked to other websites.

0

look. this website is made so we can debug your scripts. not to tell you how to start from nothing.

0

It's not to start from nothing, someone fixed my script but used a loop to do so, I simply don't understand it and want someone to elaborate. What's the point on having a script if you can't understand it, right?

0

Even so, this website isn't for what you're asking.

1 answer

✓ Accepted answer

A numerical for loop iterates through numbers at an interval. For example,

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

will print out 1 through 10. The default interval is 1.

for i=10,1,-1 do
	print(i)
end

will print out 10 through 1, where the interval is -1.

A while loop will evaluate a condition and repeat the code inside the loop while the condition holds true. A repeat loop will initially run the code inside the loop once, and repeat so long as the condition holds true. This is the same as a while loop except for the fact that it always runs through the loop once.

A generic for loop uses return values from a function, like pairs, ipairs, next, gmatch, or any other function that is meant to be used in a generic for loop. You can get a more detailed explanation of generic for here.

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