$npx -y skills add TabooHarmony/roblox-brain --skill roblox-audioUse when implementing Roblox audio playback, spatial sound, music, sound effects, SoundGroups, or dynamic audio effects.
| 1 | ## When to Load |
| 2 | |
| 3 | Load when implementing audio playback, spatial/3D sound, background music, sound effects, audio mixing (SoundGroups), or dynamic effects. Covers both legacy Sound objects and the newer modular AudioPlayer/Wire system. |
| 4 | |
| 5 | ## Quick Reference |
| 6 | |
| 7 | **Two Systems**: Legacy (`Sound`/`SoundGroup`/`SoundEffect`) — simpler. New modular (`AudioPlayer`/`AudioEmitter`/`Wire`/`AudioDeviceOutput`) — preferred for new projects, required for voice chat. |
| 8 | |
| 9 | **Sound Placement**: BasePart child → volumetric. Attachment/MeshPart → point source. SoundService/Workspace → global (BGM/UI). |
| 10 | |
| 11 | **Legacy Setup**: |
| 12 | ```luau |
| 13 | local s = Instance.new("Sound") |
| 14 | s.SoundId = "rbxassetid://ID"; s.Looped = true; s.Volume = 0.25 |
| 15 | s.RollOffMode = Enum.RollOffMode.InverseTapered |
| 16 | s.RollOffMinDistance = 10; s.RollOffMaxDistance = 100 |
| 17 | s.Parent = SoundService; s:Play() |
| 18 | ``` |
| 19 | |
| 20 | **SoundGroups** (mixer): Nest `SoundGroup` under Master for player-adjustable Music vs SFX volume. `bgMusic.SoundGroup = musicGroup`. Effects (`ReverbSoundEffect`, `EqualizerSoundEffect`, `CompressorSoundEffect`, etc.) parent to Sound/SoundGroup. Ducking: `CompressorSoundEffect` with `SideChain = sfxGroup` on music. |
| 21 | |
| 22 | **New Modular**: 2D: `AudioPlayer → Wire → AudioDeviceOutput`. 3D: `AudioPlayer → Wire → AudioEmitter` (on Part) + auto-created `AudioListener`. `SoundService.ListenerLocation` sets listener on Camera/Character. |
| 23 | |
| 24 | **One-Shot SFX**: |
| 25 | ```luau |
| 26 | local function playSFX(parent, id) |
| 27 | local s = Instance.new("Sound"); s.SoundId = id |
| 28 | s.RollOffMode = Enum.RollOffMode.InverseTapered |
| 29 | s.RollOffMinDistance = 10; s.RollOffMaxDistance = 80 |
| 30 | s.Parent = parent; s:Play() |
| 31 | s.Ended:Once(function() s:Destroy() end) |
| 32 | end |
| 33 | ``` |
| 34 | |
| 35 | **Preload**: `ContentProvider:PreloadAsync({sound1, sound2})`. **Client SFX**: `FireClient` → `OnClientEvent` creates invisible Part + `playSFX`. |
| 36 | |
| 37 | **Pitfalls**: Server sounds have latency → play feedback on client. Default `RollOffMaxDistance`=10000 studs → set explicitly. Volume > 1 clips. Rapid-fire → check `IsPlaying`. Always `Destroy()` one-shots after `Ended`. |
| 38 | |
| 39 | See `references/full.md` for detailed examples, effect table, and client-side patterns. |