Skip to main content

Documentation 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.

This quickstart takes you from a fresh installation to a fully working network setup in minutes. You will define a namespace that contains both a packet (one-way event) and a query (request/response), then wire up server-side listeners and client-side senders. By the end you will have a clear mental model of how ByteNet Max fits together.
1

Install ByteNet Max

If you have not already added ByteNet Max to your project, follow the Installation guide. Make sure the module is accessible from both the server and the client (for example, inside ReplicatedStorage).
2

Create a namespace ModuleScript

In ReplicatedStorage, create a ModuleScript named GameNetwork (or any name you prefer). This module defines a namespace that groups a packet and a query together.
-- ReplicatedStorage/GameNetwork (ModuleScript)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ByteNetMax = require(ReplicatedStorage.ByteNetMax)

return ByteNetMax.defineNamespace("PlayerData", function()
    return {
        packets = {
            -- One-way event: client tells server which key was pressed
            KeyPressed = ByteNetMax.definePacket({
                value = ByteNetMax.struct({
                    Action = ByteNetMax.string,
                    Data   = ByteNetMax.string,
                }),
            }),
        },
        queries = {
            -- Request/response: client asks server for the player's coin count
            GetCoins = ByteNetMax.defineQuery({
                request = ByteNetMax.struct({
                    message = ByteNetMax.string,
                }),
                response = ByteNetMax.struct({
                    coins = ByteNetMax.uint8,
                }),
            }),
        },
    }
end)
Both packets and queries can live in the same namespace. If you only need one of them, you can omit the other table entirely.
3

Set up the server script

Create a Script in ServerScriptService. Require GameNetwork to initialize the server side, then attach listeners to the packet and the query.
-- ServerScriptService/GameServer (Script)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GameNetwork = require(ReplicatedStorage.GameNetwork)

-- Listen for the KeyPressed packet sent by any client
GameNetwork.packets.KeyPressed.listen(function(data, player)
    print(player.Name .. " pressed: " .. data.Action)
    print("Extra data: " .. data.Data)
end)

-- Listen for GetCoins queries and return the player's coin value
GameNetwork.queries.GetCoins.listen(function(data, player)
    print(data.message) -- "Can I please get the coins value?"
    return { coins = player.leaderstats.Coins.Value }
end)
4

Set up the client script

Create a LocalScript in StarterPlayerScripts. Require GameNetwork to initialize the client side, then send the packet on input and invoke the query.
-- StarterPlayerScripts/GameClient (LocalScript)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage  = game:GetService("ReplicatedStorage")
local GameNetwork = require(ReplicatedStorage.GameNetwork)

-- Send a packet to the server on every key press
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed or input.KeyCode.Name == "Unknown" then return end

    GameNetwork.packets.KeyPressed.send({
        Action = input.KeyCode.Name,
        Data   = "Some extra context",
    })
end)

-- Invoke the query and print the result
local result = GameNetwork.queries.GetCoins.invoke({
    message = "Can I please get the coins value?",
})

print("Coins:", result.coins)
What’s next? Now that you have a working example, explore the concepts behind each building block.

Namespaces

Understand how defineNamespace organizes your networking layer.

Packets

Learn reliability modes, send targets, and listener lifecycle.

Queries

Deep dive into the request/response cycle and disconnect patterns.

Data types

Explore all built-in types including struct, array, map, and auto.

Build docs developers (and LLMs) love