Roblox Audio

TabooHarmony/roblox-brain/skills/gameplay/roblox-audio

作者 TabooHarmony38826be57ee37bcf023e9c2b85681bea3909281c無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Use when implementing Roblox audio playback, spatial sound, music, sound effects, SoundGroups, or dynamic audio effects.

AI 產生的概覽

指導 Roblox 音訊實作:播放、空間音效、音樂、音效、SoundGroup 與動態效果。

功能
為在 Roblox 體驗中實作音訊提供參考指引,涵蓋舊版 Sound/SoundGroup/SoundEffect 系統與較新的模組化 AudioPlayer/Wire 系統。內容說明音量、點聲源與全域音訊的放置方式、SoundGroup 混音與閃避、一次性音效模式、預先載入以及常見陷阱。隨附的參考檔案包含詳細範例、效果表與用戶端模式。
適用情境
適用於在 Roblox 專案中加入或偵錯音訊,例如背景音樂、3D 或空間音效、音效、音訊混音或動態效果。同時適合舊版 Sound 物件與較新的模組化音訊系統。
執行需求
不包含指令碼,僅為說明文件加一份參考檔案。需要 Roblox 開發環境(Luau 及 Roblox Studio 或執行階段 API),並需要網路存取 Roblox 資源 ID 以播放音訊。

Roblox Audio

When to Load

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.

Quick Reference

Two Systems: Legacy (Sound/SoundGroup/SoundEffect): simpler. New modular (AudioPlayer/AudioEmitter/Wire/AudioDeviceOutput): preferred for new projects, required for voice chat.

Sound Placement: BasePart child → volumetric. Attachment/MeshPart → point source. SoundService/Workspace → global (BGM/UI).

Legacy Setup:

luau
local s = Instance.new("Sound")s.SoundId = "rbxassetid://ID"; s.Looped = true; s.Volume = 0.25s.RollOffMode = Enum.RollOffMode.InverseTapereds.RollOffMinDistance = 10; s.RollOffMaxDistance = 100s.Parent = SoundService; s:Play()

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.

New Modular: 2D: AudioPlayer → Wire → AudioDeviceOutput. 3D: AudioPlayer → Wire → AudioEmitter (on Part). Studio/plugin-only SoundService.DefaultListenerLocation controls the default listener; wire an explicit AudioListener for runtime control.

One-Shot SFX:

luau
local function playSFX(parent, id)    local s = Instance.new("Sound"); s.SoundId = id    s.RollOffMode = Enum.RollOffMode.InverseTapered    s.RollOffMinDistance = 10; s.RollOffMaxDistance = 80    s.Parent = parent; s:Play()    s.Ended:Once(function() s:Destroy() end)end

Preload: ContentProvider:PreloadAsync({sound1, sound2}). Client SFX: FireClient → OnClientEvent creates invisible Part + playSFX.

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.

See references/full.md for detailed examples, effect table, and client-side patterns.

來源與署名

來源:TabooHarmony/roblox-brain位於skills/gameplay/roblox-audio提交38826be

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架