Queries are ByteNet Max’s answer toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Elitriare/ByteNet-Max/llms.txt
Use this file to discover all available pages before exploring further.
RemoteFunction. Where packets are fire-and-forget, a query lets a client send a typed request to the server and yield until the server returns a typed response. Both the request and the response are serialized into binary buffers before they cross the network, keeping the payload as compact as possible. This makes queries the right choice whenever you need data back from the server — fetching a player’s stats, requesting inventory contents, or any other read operation.
Defining a query
Queries are defined inside a namespace usingByteNetMax.defineQuery. You must provide both a request type and a response type.
request and response are required fields. ByteNet Max uses them to build separate serializers for each direction of the call.
Query API
Client-side method
| Method | Signature | Description |
|---|---|---|
invoke | invoke(request) -> response | Send the request to the server and yield until the response arrives. Returns the deserialized response. |
Server-side methods
| Method | Signature | Description |
|---|---|---|
listen | listen(callback) -> disconnect | Register a handler. The callback receives the request data and the player, and must return the response. Returns a function that disconnects the listener when called. |
listenOnce | listenOnce(callback) -> disconnect | Register a handler that runs exactly once, then disconnects automatically. |
disconnectAll | disconnectAll() | Remove every handler registered through listen or listenOnce. |
wait | wait() -> data, player | Yield the current thread until the next query arrives, then return the request data and the player. |
The disconnect pattern
listen and listenOnce both return a disconnect function. Assign the return value to a variable and call it when you want to remove that specific listener:
Complete end-to-end example
Query ModuleScript (ReplicatedStorage/QueryModule):
invoke yields the LocalScript until the server handler returns, so result is always the fully deserialized response — no callbacks or events needed on the client side.