Network
The Network module provides a unified communication layer over a single RemoteEvent and RemoteFunction pair. All networking goes through named string dispatchers — no manual remote management required.
Access via Riptide.Network.
type Callback = (...any) -> anytype Middleware = (...any) -> any
type NetworkAPI = { Register: (funcName: string, callback: Callback) -> (), Unregister: (funcName: string, callback: Callback) -> (), UseMiddleware: (scope: "server" | "client", middleware: Middleware) -> (), ClearMiddlewares: (scope: ("server" | "client")?) -> (),
-- Server-only FireClient: ((player: Player, funcName: string, ...any) -> ())?, FireAllClients: ((funcName: string, ...any) -> ())?, UnreliableFireClient: ((player: Player, funcName: string, ...any) -> ())?, UnreliableFireAllClients: ((funcName: string, ...any) -> ())?, InvokeClient: ((player: Player, funcName: string, ...any) -> any)?,
-- Client-only FireServer: ((funcName: string, ...any) -> ())?, UnreliableFireServer: ((funcName: string, ...any) -> ())?, InvokeServer: ((funcName: string, ...any) -> any)?,}Shared Methods
Section titled “Shared Methods”Register
Section titled “Register”Network.Register(funcName: string, callback: Callback) -> ()Registers a handler for a named network event or request. Multiple handlers can be registered for the same name — all will be called for events, but only the first is used for invokes.
Server example — callback receives player as the first argument:
Riptide.Network.Register("PlayerJumped", function(player, height) print(player.Name .. " jumped " .. height .. " studs!")end)Client example — no player argument:
Riptide.Network.Register("ShowNotification", function(message) print("Server says:", message)end)Unregister
Section titled “Unregister”Network.Unregister(funcName: string, callback: Callback) -> ()Removes a specific previously registered handler. Pass the exact function reference used in Register.
local function onPing(player, data) -- handleend
Riptide.Network.Register("Ping", onPing)-- Later...Riptide.Network.Unregister("Ping", onPing)UseMiddleware
Section titled “UseMiddleware”Network.UseMiddleware(scope: "server" | "client", middleware: Middleware) -> ()Adds a middleware function to the processing pipeline. Middlewares execute in order of registration and must call next(...) to continue the chain.
Server middleware signature:
Riptide.Network.UseMiddleware("server", function(player, funcName, next, ...) -- Validate, rate-limit, log, etc. if not isAuthenticated(player) then return nil -- block the request end return next(...) -- continue to handlerend)Client middleware signature:
Riptide.Network.UseMiddleware("client", function(funcName, next, ...) print("[Network] Received:", funcName) return next(...)end)ClearMiddlewares
Section titled “ClearMiddlewares”Network.ClearMiddlewares(scope: ("server" | "client")?) -> ()Clears all registered middlewares. If scope is nil, clears both server and client pipelines.
Riptide.Network.ClearMiddlewares("server") -- server onlyRiptide.Network.ClearMiddlewares() -- bothServer-Only Methods
Section titled “Server-Only Methods”These methods are only available when running on the server. Calling them on the client will error.
FireClient
Section titled “FireClient”Network.FireClient(player: Player, funcName: string, ...any) -> ()Fires a named event to a specific player.
Riptide.Network.FireClient(player, "DataLoaded", playerData)FireAllClients
Section titled “FireAllClients”Network.FireAllClients(funcName: string, ...any) -> ()Broadcasts a named event to all connected players.
Riptide.Network.FireAllClients("GlobalNotification", "Double XP activated!")UnreliableFireClient / UnreliableFireAllClients
Section titled “UnreliableFireClient / UnreliableFireAllClients”Network.UnreliableFireClient(player: Player, funcName: string, ...any) -> ()Network.UnreliableFireAllClients(funcName: string, ...any) -> ()Fires a named event over an UnreliableRemoteEvent. Perfect for high-frequency, non-critical data like particles, hitmarkers, or positional updates where dropped packets shouldn’t stall the network.
Riptide.Network.UnreliableFireAllClients("PlayerRotated", player, CFrame.new())InvokeClient
Section titled “InvokeClient”Network.InvokeClient(player: Player, funcName: string, ...any) -> anyInvokes a handler on a specific client and returns the result. Yields until the client responds.
local clientFps = Riptide.Network.InvokeClient(player, "GetFPS")Client-Only Methods
Section titled “Client-Only Methods”These methods are only available on the client. Calling them on the server will error.
FireServer
Section titled “FireServer”Network.FireServer(funcName: string, ...any) -> ()Fires a named event to the server.
Riptide.Network.FireServer("RequestPurchase", itemId, quantity)UnreliableFireServer
Section titled “UnreliableFireServer”Network.UnreliableFireServer(funcName: string, ...any) -> ()Fires a named event to the server over an UnreliableRemoteEvent. Use for extremely frequent inputs (like aim direction).
Riptide.Network.UnreliableFireServer("UpdateAimDirection", Vector3.new(0, 1, 0))InvokeServer
Section titled “InvokeServer”Network.InvokeServer(funcName: string, ...any) -> anyInvokes a handler on the server and returns the result. Yields until the server responds.
local inventory = Riptide.Network.InvokeServer("GetInventory")Architecture
Section titled “Architecture”Under the hood, Riptide creates exactly three remotes inside the package:
Riptide/shared/Remotes/├── EventDispatcher (RemoteEvent)├── UnreliableEventDispatcher (UnreliableRemoteEvent)└── FunctionDispatcher (RemoteFunction)All named events and invokes are multiplexed through these instances using the funcName string as a discriminator. This eliminates ReplicatedStorage clutter and centralizes all network traffic.