Coroutine.resume or whatever problem

Roblox throwing error through function test() and not from coroutine.resume when using wait() in function.

function test()
	wait()
	error()
end
local Thread=coroutine.wrap(function()
	test()
end)()

Is there any possible solution except removing wait() ?

3 Likes

error()

thread = coroutine.wrap(test)

You are not calling the function…
(it just not starts)

yes, you cal it:

thread()
1 Like

Can you show us how you use the coroutine.resume function in your code? We can help you with further info if you do so.

coroutine.wrap doesnt use coroutine.resume?

As much as I comprehend, the OP asks why coroutine.resume does not throw an error, rather than coroutine.wrap. Otherwise, in contrast, do they ask whether the function returned by coroutine.wrap does error without wait?

uhh maybe do this

function test()
	task.wait()
	error()
end
local Thread=coroutine.wrap(test)

Maybe try error("",2)?

The number (2) tells how far back in the stack to go when printing to the output.

@UniDevx

I’m guessing OP is wondering why the error in the output trace the error back to test then in the coroutine before coroutine.resume(...). Tou can make the error trace go back by specifying a number to the second argument of error.

1 Like

i wan’t to error goes from coroutine.wrap or coroutine.resume but i test this things and find out that is if there is any yield (for any time) it will use error() function from test() function. Specifying a ENV level doesn’t help. :face_with_diagonal_mouth: