Coroutine Questions

Hello Developers! :wave:

I have a few questions regarding coroutines. What is coroutine.yield and how can I use it. And what are some usecases of using coroutines? Thanks! :wave:

The documentation will help:

When would I use coroutine.yield, and overall, when would I use coroutines?? Thanks.

In place of Spawn() and delay() it been pointed out by many in debates like the ones I will list below that the usage of is considered bad practice and to use coroutines instead

here’s a video

2 Likes

Thanks soo much! One more question. When and what are some use-cases of when to use coroutines?

Like in the video it says “its like creating a new script” imagine using it to…

  • control multiple NPC’S
  • run a loop (wouldn’t recommend… just an example)
  • I think that’s as far as my imagination goes… :pensive:

just running multiple threads in a single script to do anything you desire tbh when the time comes just keep a mental note of what is possible if you use em