Coroutines are functions, but not meant to be ran like one. The purpose of a coroutine is to be able to run two parts of code at once, and to have better control over when to end it. For example, while loops stop the code from running until it's broken. We can get around this-
01 | x = coroutine.wrap( function () |
10 | Instance.new( "Message" ,Workspace).Text = "Messag'd!" |
This would begin the loop, wait a second, then display a message in Workspace.
You can stop this at any moment by saying-
coroutine.yield(x)
... that would stop the loop from running.
To run it again,
coroutine.resume(x)
Hope I could be of help!