I have a script which fires a function while also needing to continue, the problem is that function holds a wait in it which is necessary for the script to work as intended. Is it possible to continue the rest of the script whilst it is waiting? currently I have another script which I’ve temporarily moved the wait function to but I feel like that may not be the best way.
Call your function using spawn()
spawn(function_name)
How would I pass arguments through along with the function? I cannot seem to get it to let me pass an argument through as it tells me it needs 1 argument when it fires.
task.spawn(function_name)
Would be a better option, it is much more efficient than
spawn(function_name)
Benchmarks:
And task.spawn() can also pass arguments
task.spawn(function_name, arg1, arg2, arg3, etc)
Though coroutine would still be more efficient than task.spawn().
Thank you very much kind sir/mam!
Hey there just one more question for you real quick, how do I get a coroutine to restart from the beginning? if I let it end it just dies and isn’t usable. and if I yield and resume it just starts from the bottom of the script.
I’m not too sure about this as I haven’t used coroutines a whole lot, but you could try using a loop inside the coroutine so that it doesn’t die.