I’m trying to store threads in a table, to be able to close them later.
The issue is that when I store them in a table, they are not threads, but functions, so when I use coroutine.close(function), it will error saying it’s a function.
I tried setting the thread (which is technically a function) to nil, but it would still run, probably because I only got rid of the reference to the thread(technically function) and not the actual thread(technically function), and I couldn’t really find anything anywhere else.
Here’s a visualization of what I’m trying to do:
Threads = {}
local thread = coroutine.wrap(SomeFunction())
thread()
table.insert(Threads, thread)
--Some time later when I need to stop the thread from running
coroutine.close(Threads[1]) --THIS ERRORS
Thanks