I'm going to simplify my script here:
endroutine = false
func = coroutine.wrap(function()
while true do
wait()
--do some stuff that has to happen with other stuff unless stuff is done
if endroutine then return end
end
end)
func2 = coroutine.wrap(function()
while true do
wait()
--do other stuff that has to happen with other other stuff
end
end)
function dostuff()
--do stuff
endroutine = true
--do more stuff
endroutine = false
func()
end
func()
func2()
wait(10)
dostuff()
My issue is that when func() is called in dostuff(), I get an error along the lines of: "Unable to resume dead coroutine."
I tried the following:
endroutine = false
function func()
while true do
wait()
--do some stuff that has to happen with other stuff unless stuff is done
if endroutine then return end
end
end
func2 = coroutine.wrap(function()
while true do
wait()
--do other stuff that has to happen with other other stuff
end
end)
function dostuff()
--do stuff
endroutine = true
--do more stuff
endroutine = false
coroutine.wrap(func())
end
coroutine.wrap(func())
func2()
wait(10)
dostuff()
For some reason, the above code makes it so func2() never even runs in the first place, which is a problem since I need func() and func2() to run at the same time.
Simply put: Is there a way I can get both func() and func2() to run at the same time, and after func() has ended via "return end", be able to start it again from it's call in dostuff()?
Preferably without a lot of new lines of code; I like to try and keep my code as compact as possible.
It should be noted that in the actual script, dostuff() is called via a MouseClick event, not directly in the script.

2 comments
I just want to point out that you mispelled your variable 'endroutine' at the top of your script.
Thank you, fireheart, I've fixed it. It isn't like that in the actual script.