OnServerInvoke
For thread safety, this property is not safe to read in an unsynchronized thread.
The function called when RemoteFunction/InvokeServer
is called. This callback should be set from a Script
.
When the bound function returns, the returned values are sent back to the calling client.
This is used to retrieve remote events fired by the client and intended for the server. This event is in place to provide a method for communicating between the client and server, which is well documented in [this][1] article.
To fire from the server to the client, you should use RemoteFunction/InvokeClient
and RemoteFunction/OnClientInvoke
.
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The |
||
|
Arguments passed to |
Expected return type:
Return Type | Summary |
---|---|
Values returned by the function are returned by |
Code Samples
RemoteFunctions: Client to Server
When a client wants to use a remote function, it will invoke the server with the RemoteFunction/InvokeServer
function within a LocalScript
.
The server listens for this function to be invoked by binding a function to RemoteFunction/OnServerInvoke
using the assignment operator =, and not with an event within a Script
. When the server is invoked, it will execute the bound function.