How to use one coroutine.wrap function twice

so i want to use a coroutine.wrap function two times but i get this:
image

What I typically do is encase the code inside of the coroutine inside of a while true do loop and at the end of the code, I would do coroutine.yield

Example

local func = coroutine.wrap(function()
    print("Hello")
end)

func()
func() --coroutine is dead here

I would turn it into

local func = coroutine.wrap(function()
    while true do
       print("Hello")
       coroutine.yield()
    end
end)

func()
func() --coroutine  will still work

If you have parameters in your coroutine you will have to do a bit of a change with the code I’ve shown, something like this

local func = coroutine.wrap(function(test)
    while true do
       print(test)
       test = coroutine.yield()
    end
end)

func("Hello") --Prints hello
func("Hi") -- Prints Hi

I am unsure how good this method is has I’ve always done it like this

oh, thanks for answering. i have found a solution already tho, you can just put the coroutine into a function so each time you call the function it creates a new coroutine

An easier way in my opinion is

coroutine.resume(coroutine.create(function()
-- u can do this again in here
end