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

Is it possible to run the same co-routine function twice at the same time?

Asked by 9 years ago

Suppose that I have a co-routine function and I want it to be ran two and run at the same time so that they execute the same code but there's something uniquely different in that code. Is this possible?

For instance, I have a script that has a function that rotates a gui. I want to use that function to rotate a gui, another gui, another gui, and then one last gui and run that function (4 times) at the same time. It's co-routine. I tried it but for some reason it's not letting me run the same function(2 times at the same time).

Does anybody know?

0
You could just make the script access all guis at once.. Goulstem 8144 — 9y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The same coroutine can't be run twice at the same time. That's not what coroutines are.

Instead, make a new coroutine (but it can still wrap up the same function).


If you just need new threads and aren't using coroutines as coroutines, consider using spawn(func) instead of coroutine.resume( coroutine.create( func ) ) or coroutine.wrap(func)().

Ad

Answer this question