Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

the weird thing about using coroutine wrap and checking the status?

Asked by 5 years ago
local naaa = coroutine.create(function()
    print("hi")
end)
print(coroutine.status(naaa))
wait(1)
coroutine.resume(naaa)
wait(1)
print(coroutine.status(naaa))

yes this is the correct script by using coroutine.create but down here, things get weird

local naaa = coroutine.wrap(function()
    print("hi")
end)
print(coroutine.status(naaa))
wait(1)
naaa()
wait(1)
print(coroutine.status(naaa))

now if you test the code the error comes out "- Workspace.Script:4: bad argument #1 to 'status' (coroutine expected)", i just wanna ask why is it like that?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

coroutine.wrap returns a function that is used the same way you would use coroutine.resume(). It does not return a thread reference that you can use with coroutine.status(), unfortunately. That's one of the things you lose when using this wrapper, you get no reference to the thread itself.

Ad

Answer this question