This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
Invoke will call the OnInvoke callback and return any values that were returned by the callback (if any). If the OnInvoke callback is not set, this method will yield until one is set. If OnInvoke yields, this method will also yield. There are limitations on the values that can be sent as arguments; see the code samples.
This code sample sets the OnInvoke callback of the parent BindableFunction to a function that returns the sum of two numbers. Test this code sample by pasting this code inside a Script within a BindableFunction. You’ll then be able to use Invoke on the BindableFunction from other scripts.
BindableFunction Valid Values
This code sample shows the kinds of values that can be sent to and from BindableFunctions via Invoke/OnInvoke. Test this code by placing a Script within a BindableFunction inside the Workspace or ServerScriptService. It will raise errors on the values that cannot be sent.