RemoteFunction

Show Deprecated

The RemoteFunction object facilitates synchronous, two-way communication across the client-server boundary. You can use it to define a custom callback function and invoke it manually by calling RemoteFunction:InvokeClient() or RemoteFunction:InvokeServer(). The code invoking the function yields until it receives a response from the recipient.

In order for both the server and clients to access a RemoteFunction instance, it must be in a place where both sides can see it, such as ReplicatedStorage, although in some cases it's appropriate to store it in Workspace or inside a Tool.

If the result is not needed, it is recommended that you use a RemoteEvent instead, since its call is asynchronous and doesn't need to wait for a response to continue execution. See Remote Events and Callbacks for code samples and further details on RemoteFunction.

Streaming Precautions

Note that if an invoked RemoteFunction creates an instance on the server, there is no guarantee that it exists on the client when the function returns. This is particularly important in places where instance streaming is enabled and when the created instances are BaseParts or Models, since parts that are far away from the player's character may not be streamed to the client, and models that are Atomic depend on whether their parts are streamed. Even if a model is Persistent, there may be some delay between the creation of the model and when it is replicated to the client.

Parameter Limitations

Any type of Roblox object such as an Enum, Instance, or others can be passed as a parameter when a RemoteFunction is invoked, as well as Luau types such as numbers, strings, and booleans, although you should carefully explore the limitations.

Summary

Methods

Callbacks

Properties

Methods

InvokeClient

Yields

Parameters

player: Player
arguments: Tuple

Returns

InvokeServer

Yields

Parameters

arguments: Tuple

Returns

Events

Callbacks

OnClientInvoke

Parameters

arguments: Tuple

Returns

OnServerInvoke

Parameters

player: Player
arguments: Tuple

Returns