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 从公开仓库中收录这些内容。

举报或申请下架