Channel — Server API
When RunService:IsServer() is true at require-time, every Channel exposes the server method set below. These translate 1:1 onto the underlying ByteNet packet's own methods, plus the middleware pipeline on on.
Method Table
| Method | Signature | Description |
|---|---|---|
sendTo | (self, player: Player, data: any) -> () | Sends data to a single player. |
sendToAll | (self, data: any) -> () | Broadcasts data to every connected player. |
sendToAllExcept | (self, player: Player, data: any) -> () | Broadcasts data to all players except player. |
on | (self, callback: (data: any, player: Player) -> ()) -> () | Registers a listener for packets sent from clients. Runs the middleware chain before invoking callback. |
KravasNet's public Channel:sendTo(player, data) keeps the classic
argument order (player first). Under the hood, ByteNet 0.4.x packets
actually take (data, player) — KravasNet translates this for you, so
your calling code never has to think about it.
sendTo
CombatNet.Damage:sendTo(player, { amount = 50, target = player.Character })Sends the packet directly to one client.
sendToAll
CombatNet.Position:sendToAll({ pos = Vector3.new(0, 10, 0) })Broadcasts to every player currently in the Players service.
sendToAllExcept
CombatNet.Damage:sendToAllExcept(attacker, { amount = 25, target = victim.Character })Useful for excluding the player who triggered an event (e.g. avoid echoing an action back to its source).
on
CombatNet.Position:on(function(data, player)
print(player.Name, "reported position", data.pos)
end)Registers a server-side handler for packets sent by any client via Channel:send(). The player argument identifies the sender.
See Channel — Client API for the client-side method set.