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

Can someone help me?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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.

0
(this question does not belong on this site) http://wiki.roblox.com/index.php?title=Conditional_statement lukeb50 631 — 8y
0
It's a question about scripts and I asked to not be linked to other websites. TetsuyaMitsuru 10 — 8y
0
look. this website is made so we can debug your scripts. not to tell you how to start from nothing. lukeb50 631 — 8y
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? TetsuyaMitsuru 10 — 8y
0
Even so, this website isn't for what you're asking. Scootakip 299 — 8y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

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.

Ad

Answer this question