Hello, friend!
How many times has this happened to you!?!?!?
-- somewhere in your lua code...
game.OnClose = function()
ImportantCleanupFunction1()
end
-- somewhere else in your lua code
game.OnClose = function()
ImportantCleanupFunction2()
end
You try and try, but no matter what you do only one of the ImportantCleanupFunctions gets called!!
Sure, you could make one function that calls all of your other functions. But that leads to awkward code interdependencies, bloating, cramps, and unsightly stretch marks.
Oh, can’t someone DO something?!??!
Yes, ROBLOX can!! Introducing the amazing new “game.BindToClose”. With game.BindToClose, you can:
- Bind an arbitrary number of functions to the close event!
- See your bound functions execute in parallel on game end!
- Marvel as the game waits until all of your bound functions finish (assuming they finish within 30 seconds)!
- Rest assured that if there’s a game.OnClose function, it will be called (in parallel with other calls).
You may say, “Gee, that sounds great. But won’t it be confusing to use?”
No WAY, Juanita! Check it out:
game:BindToClose(function()
print("Starting callback...")
wait(5)
print("Done callback...")
end)
Just listen to this real life testimonial!
“Before game.BindToClose, I was a real mess. My code was convoluted and I couldn’t use third party code for fear that they’d override my OnClose function. Now, with game.BindToClose, everything is coming up roses! Licked those intestinal problems to boot!"
–BobStars
Available in your API NOW!!