So I have a simple combo script, and I’m using coroutine instead of spawn. For better performance.
Coroutine
local breakCombo = coroutine.wrap(function()
wait(1.2)
combo = 1
print("Broke combo!")
coroutine.yield()
end)
-- alternate one as well with a parameter
local breakCombo = coroutine.wrap(function(combo)
if combo == combo then
wait(1.2)
combo = 1
print("Broke combo!")
coroutine.yield()
else return end
end)
I’m only able to use this function once, and I thought yielding would prevent it from dying.
So my main question is, how can I use this function multiple times throughout my script?
And seems like it is giving a error inside the coroutine, the state of a coroutine being dead is returned once the function inside the coroutine gives a error.
local breakCombo = function()
wait(1.2)
combo = 1
print("Broke combo!")
coroutine.yield()
end
coroutine.wrap(breakCombo)() -- Start 1 coroutine
coroutine.wrap(breakCombo)() -- Start another coroutine
local breakCombo = function(combo)
if combo == combo then
wait(1.2)
combo = 1
print("Broke combo!")
coroutine.yield()
else return end
end
coroutine.wrap(breakCombo)(arg1) -- Start 1 coroutine with param
local cor = coroutine.wrap(breakCombo) -- Start another coroutine with param/ different style
yielded_ret = cor(arg2)