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

How to loop? [closed]

Asked by 9 years ago

How do you make a loop?

0
This Question has been asked and answered multiple times; Please use the Search-Engine to check for any past or existing Questions of this type. :) TheeDeathCaster 2368 — 9y

Closed as Not Constructive by TheeDeathCaster, NinjoOnline, and M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Since I'm not at home, I can't give you a proper link, but go to wiki.roblox.com, and search loops. There's a couple: While, Generic For, Numeric For, repeat, etc.

Ad
Log in to vote
1
Answered by
Mauvn 100
9 years ago
while wait() do
--insert code here
end

This is pretty much a basic loop but remember there are many other loop forms and not just the while wait() version.

You could also make a loop using .Stepped and .Heartbeat for server scripts or .RenderStepped for local scripts in RunService which both of them are faster than the while wait() form

game:GetService("RunService").RenderStepped(function() --locals only
end)
game:GetService("RunService").Stepped(function() --server sided only
end)
game:GetService("RunService").Heartbeat(function() -- server sided only
end)

or you could just use a for loop