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

How do i do 3 while true do loops at once?

Asked by 10 years ago

Spawn(function() while wait(3) do print("3seconds") --Prints "3seconds" every 3 seconds and "0.1second" every 0.1 second end end) while wait(0.1) do print("0.1second") end

Help?

1
..Just add another Spawn? User#2 0 — 10y
1
i tried that..hmm tkddude2 75 — 10y
1
thx for the effort though tkddude2 75 — 10y

3 answers

Log in to vote
2
Answered by
User#2 0
10 years ago

As I said earlier, adding another spawn should fix this. I did forget to mention that you had to use the spawn before your final while loop.

Spawn(function() 
        while wait(5) do 
            print("5seconds")   --Prints "5seconds" every 5 seconds and "0.1second" every 0.1 second
    end
end)

Spawn(function() 
        while wait(3) do 
            print("3seconds")   --Prints "3seconds" every 3 seconds and "0.1second" every 0.1 second
    end
end)

Spawn(function() -- keep the program looking consistent, and in case you need/want to do something AFTER this part of the script
     while wait(1) do -- I changed this to 1 btw.
            print("1second")
    end
end)
Ad
Log in to vote
1
Answered by 10 years ago
coroutine.resume(coroutine.create(function()
while wait() do
--first loop
end
end))

coroutine.resume(coroutine.create(function()
while wait() do
--second loop
end
end))

coroutine.resume(coroutine.create(function()
while wait() do
--third loop
end
end))
0
Spawning a function is better practice for this type of thing because it's more efficient (because it's merely designed to do just that.) nate890 495 — 10y
Log in to vote
-5
Answered by 10 years ago

http://wiki.roblox.com/index.php?title=Function_dump/Coroutine_manipulation

<- someone pointed to me for this if anyone else had the same question

BUT STILL ANSWER IF THERE IS ANOTHER WAY

0
You didn't simplify it for him.. Shawnyg 4330 — 10y

Answer this question