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

How to loop?

How do you make a loop?

1 comment

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. :)

2 answers

✓ Accepted answer

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.

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

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