Question about coroutines

If I were to have a server script function that runs coroutine.wrap every time let’s say a proximity prompt is fired. Would that function create multiple threads?

For example: 2 players activate a proximity prompt at once

blahblah.ProximityPrompt.Triggered:Connect(function(player)
     print(player)
end)

--> Player1?
--> Player2?

OR

--> Player1 or Player2? (Same as no coroutines)

Coroutines run on a separate thread from the main one, so for example if it fails it won’t yield the main thread 2 separate codes can run at the same time

That would mean that only one thread would be created from the mentioned script above?

It would create a new thread, however if you want there’s an article here about them as well you can look at Coroutines - When and how to use them

1 Like