Thread expected, got Function

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to continue a thread after yielding it.

  2. What is the issue? Include screenshots / videos if possible!
    The thread I’m using is considered a “function” to the code, whenever I run the code it always trigger “invalid argument #1 to ‘status’ (thread expected, got function)”. I also tried doing this without “start()” at the first place.

start=coroutine.wrap(untilEnd)

function restart()
	script.Countdown.Value=script.StartValue.Value
	if coroutine.status(start)=='suspended' then
		coroutine.resume(start)
	else
		start()
	end
end
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried searching for similar topics to this, unfortunately there wasn’t any posts that mentioned this issue.
1 Like

coroutine.wrap returns a function that can be called synchronously regardless of any yields; coroutine.create is what you’re looking for as it returns a thread instead of a function.

3 Likes

That’s something new to me, thanks for the help!
I don’t actually need coroutine.create anymore because there was some issues going with it.

1 Like