Networking that stays understandable¶
ByteNet Max is a typed, buffer-based networking library for Roblox. Define each message once, share that definition between the server and client, and use packets for events or queries for request/response calls.
Build your first packet Install ByteNet Max
Required: initialize on the server and client¶
The same shared namespace ModuleScript must be required by a server Script and a LocalScript. The server should initialize first. Without both sides, ByteNet Max cannot establish matching packet, query, and struct mappings, and networking will fail.
Packets¶
Send one-way messages through reliable or unreliable channels. ByteNet Max batches packet traffic once per frame.
Queries¶
Send a typed request from a client and receive a typed response from the server—without manually creating a RemoteFunction.
Shared definitions¶
Keep packet and query schemas in a shared ModuleScript. The same schema gives both sides a consistent wire format.
The complete shape¶
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ByteNetMax = require(ReplicatedStorage.Packages.ByteNetMax)
return ByteNetMax.defineNamespace("Game", function()
return {
packets = {
ShowToast = ByteNetMax.definePacket({
value = ByteNetMax.struct({
Message = ByteNetMax.string,
}),
}),
},
queries = {
GetCoins = ByteNetMax.defineQuery({
request = ByteNetMax.nothing,
response = ByteNetMax.uint32,
}),
},
}
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Network = require(ReplicatedStorage.Network)
Network.queries.GetCoins.listen(function(_, Player)
return Player:GetAttribute("Coins") or 0
end)
Network.packets.ShowToast.sendTo({ Message = "Welcome!" }, game.Players:GetPlayers()[1])
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Network = require(ReplicatedStorage.Network)
Network.packets.ShowToast.listen(function(Data)
print(Data.Message)
end)
local Coins = Network.queries.GetCoins.invoke(nil)
print(`You have {Coins} coins`)
Do not skip network initialization
The server and client must both require the same namespace ModuleScript. Put it in ReplicatedStorage, require it from a server Script first, and require it again from a LocalScript. See the exact setup.
Pick the right tool¶
| You need to… | Use | Example |
|---|---|---|
| Notify the server or a client | Packet | Equip an item, show an effect |
| Broadcast to several clients | Packet | Round state, announcement |
| Send frequent disposable state | Unreliable packet | Aim direction, cosmetic position |
| Ask the server for a result | Query | Fetch a profile summary |
ByteNet Max is based on ByteNet, but this documentation describes ByteNet Max's current source and API.