PcoWSkbVqDnWTu_dm2ix
The information on this page may no longer be accurate. To see the latest, go to our new and improved documentation. You can also learn more about the future of documentation.
Collapse Sidebar

OnServerInvoke

RemoteFunction

Tuple

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 Player corresponding to the client where the RemoteFunction/InvokeServer function call originated from.

Arguments passed to RemoteFunction/InvokeServer are passed to the function.

Expected return type:

Return Type Summary

Values returned by the function are returned by RemoteFunction/InvokeServer (back to the client).


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.