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

How to make a script repeat itself over and over again?

Asked by 5 years ago

Can someone teach me how to make a script that repeats its over and over and over again.

4 answers

Log in to vote
1
Answered by 5 years ago

Hello!

Use a while loop.

while true do
    print("I'm cool")
    wait()
end

Make sure to add a wait() in there or studio will crash!

0
It doesn't crash, it hangs. User#19524 175 — 5y
0
Well with my literal bucket of garbage computer it does. Chardinok 5 — 5y
Ad
Log in to vote
0
Answered by
aazkao 787 Moderation Voter
5 years ago
Edited 5 years ago

This while loop will loop forever in a script as long as the variable condition is true

local condition = true
while condition do 
wait()
end

Additionally you can head over to https://www.robloxdev.com/articles/Roblox-Coding-Basics-Loops to learn more about looping and how it works

Log in to vote
0
Answered by 5 years ago

while true do is the easiest loop you can have,

while true do
    elite hacker code here
end
Log in to vote
0
Answered by 5 years ago

This depends if you want it too go on forever or a set amount of time.

If you would like it to repeat a certain amount of times do this.

for i = 0,100 do
--Code here
end

Change '100' too whatever number you want.

If you would like it to repeat forever do this

while true do
wait()--make sure you have this. Without it. It will crash the Server/Client.
end

If this helps. Make sure to accept my Answer.

Answer this question