Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can I make a global coroutine?

Asked by
Validark 1580 Snack Break Moderation Voter
9 years ago

I am sure you can make global functions by using _G, but how do you make global coroutines?

2 answers

Log in to vote
1
Answered by 9 years ago
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)
Ad
Log in to vote
0
Answered by 9 years ago

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:

http://wiki.roblox.com/index.php?title=OnInvoke

Answer this question