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

How to make script Loop 4ever in Roblox Studio - it's possible ?

How to make Loop for ever in local script - Roblox Studio ? It's possible ?

  • Thank you and best regards !

-PPJASK

2 answers

✓ Accepted answer

You can do multiple ways.

one, you can use the while do condition:

while true do
    wait() -- NEEDED ELSE THE SCRIPT WILL CRASH YOUR GAME / STUDIO
    print('SUP')
end

alternatively you can use while wait() do

two, you can use runservice ( renderstepped is only for local scripts ):

local RS = game:GetService("RunService")

RS.RenderStepped:Connect(function()
     warn('LOOP!')
end)

three, you can use runservice ( stepped ):

local RS = game:GetService("RunService")

RS.Stepped:Connect(function()
     warn('LOOP!')
end)

four, you can use the repeat condition:

( THIS IS FOR WHEN YOU WANT IT TO STOP AT A CERTAIN POINT )

local Timer = 0

repeat
  wait()
    warn('Time: ' .. tostring(Timer))
    Timer = Timer + 1
until Timer == 10

warn('Timer has reached 10!')

links for learning:

RunService - Here

Loops - Here

^ Loops is repeat and while

Yes, it is possible to make your script loop forever. It takes a few lines of code to make that happen. What you want to firstly do is add a "while true do" in your script. Which will make it loop infinitely.

The code for this script is fairly simple

while true do
wait()
--Your infinite code will go here
end

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