360 Secure SkillHub
360 安全技能中心

roblox-audio

该 Skill 面向 Roblox 音频开发,涵盖 Sound/AudioPlayer 两套系统、2D/3D 声音、SoundGroup 混音、音效与动态效果,并给出 Luau 示例、预加载、客户端播放和常见问题排查建议,需在 Studio 中验证。

TabooHarmony
热度 0.00
最近更新 2026-10-18 22:40:28
分类:开发依赖:纯提示词应用场景:代码生成 / 调试排错 / 概念解释

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add tabooharmony/roblox-brain/roblox-audio
Metadata
name
roblox-audio
description
Use when adding, changing, or fixing Roblox audio: playback, spatial sound, music, sound effects, SoundGroups, or dynamic effects.
when_to_use
Also when a sound doesn't play, is too loud or quiet, overlaps or loops wrongly, volume settings, and auditing audio assets or mixes.
last_reviewed
"2026-10-14T00:00:00.000Z"
sources
["https://create.roblox.com/docs/reference/engine/classes/SoundService","https://create.roblox.com/docs/audio/objects","https://create.roblox.com/docs/audio/effects","https://create.roblox.com/docs/sound/groups","https://create.roblox.com/docs/sound/dynamic-effects","original","https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/reference/engine/classes/Sound.yaml"]

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:

local s = Instance.new("Sound")
s.SoundId = "rbxassetid://ID"; s.Looped = true; s.Volume = 0.25
s.RollOffMode = Enum.RollOffMode.InverseTapered
s.RollOffMinDistance = 10; s.RollOffMaxDistance = 100
s.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:

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.