I am trying to pause/destroy a coroutine from outside the coroutine and it keeps giving me an error. I dont use coroutines alot so I’m not sure what I’m doing wrong.
I’ve made a new place file and made this minimum reproducible error. It errors everytime, no matter if I use coroutine.resume(coroutine.create()), task.spawn, etc. It also errors if I try coroutine.close. There is no other code in this placefile other than these 7 lines. I’ve also tried putting waits to see if I was just closing it too fast and it still didn’t work.
Is anyone else having the same error?
local t = task.spawn(function()
for i = 1, 100 do
wait(1)
end
end)
wait(1)
task.cancel(t)