So I am making a script, and I was testing if something I needed in my script works. So here is what I did to test.
function f() local c = coroutine.wrap(function() while wait(1) do print('yay') end end) c() wait(5) return end f()
It prints "yay" more then 10 times. What would I do to yield a coroutine outside of the coroutine, and why does using return on the function the coroutine is on not stop the coroutine?
local c = coroutine.wrap(function() while wait(1) do print('yay') break end end) local function f() wait() return c() end f()
Hopefully, this is an answer that should work (I'm not the best with coroutines.)
The reason you can make it stop is to make it a for anystringhere = 1,40 do -- code here end
like this for example
stop = true function f() local c = coroutine.wrap(function() if stop == true then for n = 1,40 do wait() print('yay') end stop = false end end) c() wait(5) return end f()