I have just learned about coroutines, and i'm curious... could I revive a coroutine? I tryed this; and it says that the coroutine is dead.
local p = coroutine.wrap(function() print(1) end local c = coroutine.wrap(function() print(2) end while wait(1) do p() c() end
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-
x = coroutine.wrap(function() while wait(1) do print(":)") end end) wait(1) 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!