I’ve tried using coroutines in my scripts, and i’ve been using coroutine.wrap() when scripting due to not being able to make normal coroutines come back to life, and that hasn’t been working (coroutines just coming as dead), so i was wondering if anybody could enlighten me with knowledge on how to fix this.
(i know there’s another post just like this but i cant understand the garbled code in the solution, so im wondering if somebody else can provide a good solution here without me reviving a post over a year old)
You can just create a new coroutine when you want to run it again:
local function DoSomething()
print("Something")
task.wait(1)
print("After wait")
end
local function DoSomethingInACoroutine()
coroutine.resume(coroutine.create(DoSomething))
end
DoSomethingInACoroutine()
DoSomethingInACoroutine()
-- Something
-- Something
-- After wait
-- After wait