voicechat.incomingpacket:Connect Asynchronous

Subscribe to inbound culling messages and decrypted WebRTC RTP packets. The callback runs on a deferred Luau task.

Syntax
Luau
voicechat.incomingpacket:Connect(callback: (VoicePacket) -> ()) -> VoicePacketConnection

Parameters

Call this method with a voicechat.incomingpacket receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.

Function parameters
ParameterTypeDescription
callback(VoicePacket) -> ()Function receiving a VoicePacket table.

Argument fields

VoicePacket fields
Luau
VoicePacket = {
  Data: buffer, Channel: "data" | "rtp",
  Direction: "outgoing" | "incoming",
  Injected: boolean, Accepted: boolean
}

Returns

VoicePacketConnection

A connection with Connected and Disconnect.

VoicePacketConnection fields
Luau
VoicePacketConnection = {Connected: boolean, Disconnect: Function}

Usage notes

VoicePacket.Data is an owned buffer snapshot. Use :Disconnect() when finished. The observer does not change or block the packet.

Example

Example
Luau
local connection = voicechat.incomingpacket:Connect(function(packet)
    print(packet.Channel, buffer.len(packet.Data))
end)
-- connection:Disconnect()