Skip to content

Net

Net wraps buffer-packed RemoteEvent and RemoteFunction instances under ReplicatedStorage.CluauppNet. Names are unique per game; payloads are encoded with an internal codec (not JSON on the wire). Use Flare for schema-driven networking; Net is the manual escape hatch.

Header: #include <clpp/libs/net.clh>. Runtime: CluauppLibs.Net.

  • Quick ad-hoc remotes when you do not want a .flare schema yet.
  • Typed-ish overloads in CL++ (Fire with zero to three args) without templates inside structs.
  • Server/client guardsFire / Invoke assert on the server; FireServer / InvokeServer assert on the client.
  • Ward on the server — non-buffer payloads, oversized packets, and decode failures are struck instead of unpacked.

When not to use: production gameplay traffic (prefer Flare .flare schemas — connection example), or when you need unreliable batches and query RPCs.

#include <clpp/roblox.clh>
#include <clpp/libs/net.clh>
NetEvent CoinsChanged = Net.Event("CoinsChanged");
[[server]]
void initServer() {
CoinsChanged.On(func (Player player, int amount) {
// server received from client
});
}
[[client]]
void initClient() {
CoinsChanged.On(func (Player player, int amount) {
// player is nil on client; amount is decoded
});
CoinsChanged.FireServer(50);
}

Returns: NetEvent handle bound to ReplicatedStorage.CluauppNet/<name> (creates the remote on the server).

When: Named fire-and-forget messages.

Example

NetEvent E = Net.Event("MyEvent");

Returns: NetFunction handle for request/response RPC.

When: Client asks server (or server asks client) for a return value.

Example

NetFunction GetLevel = Net.Function("GetLevel");

Returns: Luau nil. Sends encoded args to one client (server only).

When: Targeted replication (inventory sync, hit confirmation).

Example

CoinsChanged.Fire(player, 100); // client receives 100

Returns: Luau nil. Broadcasts to every client (server only).

When: Global announcements or shared world state.

Example

CoinsChanged.FireAll(0); // all clients get 0

Returns: Luau nil. Client → server (client only).

When: Player actions that must be validated on the server.

Example

CoinsChanged.FireServer(25);

Returns: RBXScriptConnection — disconnect to stop listening.

When: Handling incoming events. On the server, callback receives Player then args; on the client, Player is nil and args follow.

Example

CoinsChanged.On(func (Player p, int n) {
post(n); // decoded value
});

Returns: Luau nil. Registers the invoke handler (replaces prior handler).

When: Implementing the authority side of an RPC.

Example

GetLevel.On(func (Player p) {
return 7; // encoded back to caller
});

Returns: auto — decoded return value from the client (server only).

When: Server needs data from a specific player’s client (use sparingly).

Example

int level = GetLevel.Invoke(player); // 7

Returns: auto — decoded return value from the server (client only).

When: Client requests authoritative computation.

Example

int level = GetLevel.InvokeServer(); // 7