How do I make coroutines run from the start every time it's called?

How do I make a coroutine that runs from the start every time it is called, instead of resuming the previous run? Basically make it run like a function would when it’s called. I’m new to coroutines, need guidance… image

Right now if I call the coroutine again before the previous run finishes, it will resume the previous run instead of starting a new run from the top.

To make it start from the top each time, create a new thread each time.

local function Receiver(origin,bs,destination)
    --the code
end

and to create it each time

local function ToQvl(hit)
    --before
    local thread = coroutine.create(Receiver)
    coroutine.resume(thread,"DP",hit,"QV")
    --after
end
1 Like

It does initiate the coroutine, but doesn’t run the line after until the coroutine has completed. How do I make it so it continues running image

You call Receiver, so are you sure its the thread that is being run, and not where you called Receiver?

Also, you can put your code in the message,

```
local h = print()
```
becomes

local h = print()

My bad forgot to take out that line.