Remote Procedure Calls (RPCs) let you invoke a method across the network so it runs on one or more connected clients. s&box provides three RPC targeting modes —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt
Use this file to discover all available pages before exploring further.
Rpc.Broadcast, Rpc.Host, and Rpc.Owner — and a set of NetFlags to control delivery and permissions. This page explains all three modes, how to restrict who may invoke an RPC, and how to filter recipients at call time.
The three RPC attributes
Decorate any instance or static method with one of the three nested attributes insideRpc:
- Rpc.Broadcast
- Rpc.Host
- Rpc.Owner
The method runs on every connected client including the host.Call it normally from the owner or from the host:
Before the RPC method body runs on remote clients, any
[Sync] properties and
the GameTransform of the target object are brought up-to-date. The only
exception is properties marked with SyncFlags.Query, which are updated on the
regular network tick cadence.NetFlags: delivery and permission flags
Every RPC attribute accepts an optionalNetFlags argument. Flags can be combined with |.
Delivery flags
| Flag | Description | ||
|---|---|---|---|
NetFlags.Reliable | Delivery is guaranteed; retransmitted until acknowledged. Default for all RPCs. | ||
NetFlags.Unreliable | Best-effort delivery. May arrive out of order or not at all. | ||
NetFlags.SendImmediate | Do not batch with other outgoing messages; send right away. | ||
NetFlags.UnreliableNoDelay | `Unreliable | SendImmediate | DiscardOnDelay`. Use for streaming data such as voice. |
Permission flags
| Flag | Description |
|---|---|
NetFlags.HostOnly | Only the host may invoke this RPC. Clients that call it are ignored. |
NetFlags.OwnerOnly | Only the owner of the object may invoke this RPC (or the host for static RPCs). |
Reading Rpc.Caller
Inside any RPC method body you can find out which connection triggered the call:Rpc.Calling is true only while the method body is running as a result of a remote call. When running locally (the same client that invoked it), Rpc.Calling is false.
Filtering recipients at call time
Rpc.Broadcast sends to every client by default. You can narrow the recipient list at call time using Rpc.FilterInclude or Rpc.FilterExclude. Both return an IDisposable — place them in a using statement so the filter is removed after the call:
Only one filter can be active at a time. Nesting
FilterInclude or
FilterExclude inside an already-active filter throws an
InvalidOperationException.Static RPCs
RPCs can be declared on static methods. A staticRpc.Broadcast sends a message with no object context; the engine routes it using just the class and method name:
NetFlags.OwnerOnly behaves like NetFlags.HostOnly because there is no object with an owner to check against.
How RPCs interact with [Sync] properties
RPCs and synced properties are designed to work together. The engine guarantees that by the time an RPC method body runs on a remote client, all[Sync] properties on the same object reflect the state the sender had at the moment the RPC was called:
SyncFlags.Query are the exception — they are updated on the normal unreliable snapshot cadence, not flushed ahead of RPCs.
Practical patterns
- Client → host request
- Host → all clients event
- Host → owner notification
Next steps
Sync vars
Keep component properties in sync automatically with
[Sync] and SyncFlags.Networking overview
Revisit the host/client model,
NetworkObject, and ownership.