I am sure you can make global functions by using _G, but how do you make global coroutines?
✓ ANSWER ACCEPTED
Can I make a global coroutine?
2 answers
✓ Accepted answer
local function WaitAndPrint()
for i = 10, 0, -1 do
print(i)
wait(1)
end
end
_G.WaitAndPrint = coroutine.create(WaitAndPrint)
And in another script...
wait(1)
coroutine.resume(_G.WaitAndPrint)
Just use a BindableFunction. You can use the OnInvoke callback to fire a function when the BindableFunction is invoked, then you can invoke the BindableFunction in a coroutine.
More information:
This discussion is preserved as it was. New answers, comments, and votes are closed.
