Project index/01 — Luau
Case study / 01Source-inspected

Audio System.

A Roblox audio layer that separates server-side recipient routing from client-owned playback and cleanup.

CategoryLuau
FocusClient/server audio subsystem
TechnologyLuau / Roblox Audio API / ByteNet packets
StatusSource-inspected
01 / Overview

Why it exists

Give game systems one service for targeted or broadcast playback while the listening client owns its audio graph.

The source handles channel routing, positional emitters, playback handles, and resource cleanup across a server/client boundary.

Based on the Audio System code in the local commons-area repo.

02 / System

How it works

  1. 01

    Select listeners

    AudioService validates a play request and chooses a broadcast or specific players.

  2. 02

    Send packet

    A Play packet carries a handle ID, channel, source, options, and optional target or emitter group.

  3. 03

    Build playback

    AudioController creates AudioPlayer and AudioFader records, wiring them into a channel mixer or emitter.

  4. 04

    Release resources

    The client disconnects Ended, cancels delayed stops, and destroys wires, players, and faders when a record ends.

03 / Code

Selected code

These excerpts are from the paths shown on each patch. Select an annotation for a focused note; copy code directly from each patch.

luau / source excerpt

AudioService.luau

commons-area/src/server/Services/AudioService.luau

Validates a play request, creates a handle, and routes the packet to all or selected players. It is the server half of the audio boundary.

Notes on the patch
luau / source excerpt

AudioController.luau

commons-area/src/client/Controllers/AudioController.luau

Tears down one playback record, including its connection, delayed task, wires, player, and fader. This makes handle cleanup explicit.

Notes on the patch
04 / Decisions

Engineering decisions

01

Server chooses recipients

Reason
The server service owns broadcast and targeted packet delivery.
Alternative
Each feature sends and manages its own playback messages.
Tradeoff
AudioService becomes the shared routing boundary.
02

Client owns the graph

Reason
Per-listener AudioPlayer, AudioFader, emitter, and wire lifetimes stay with playback.
Alternative
Leave instances to incidental cleanup.
Tradeoff
The controller must maintain handles and teardown paths.
05 / Reflection

Outcome & next steps

Outcome

The inspected source implements shared packet routing and client-owned playback records with explicit teardown.

What improved

The source keeps listener selection separate from per-client audio graph lifetimes.

Current limitations

  • This audit did not include an in-experience audio test or recording.
  • Individual contribution within the collaborative repository was not independently verified.

Future improvements

  • Add a runtime capture and tests for playback routing and teardown.

What this demonstrates

Luau service boundaries, packet delivery, graph construction, and lifecycle cleanup.

Continue readingValor