PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

SoundGroup

Sound

SoundGroup

The SoundGroup that is linked to this Sound. SoundGroup/Volume and SoundEffects applied to this sound group will pass onto the sound. A sound can only be in one sound group at a time.

SoundGroups are used to manage the volume and effects of multiple Sounds at once. A Sound is added to a SoundGroup by setting the SoundGroup property of the sound.


Code Samples


SoundGroups

This sample demonstrates how a SoundGroup can be used to change the volume of its associated Sounds and apply SoundEffects.

In this example a Sound is instanced in the Workspace and assigned to a new SoundGroup. The Sound is played and during playback the volume is changed via the SoundGroup and a SoundEffect is added.

local SoundService = game:GetService("SoundService")

-- create a sound group
local soundGroup = Instance.new("SoundGroup", SoundService)

-- create a sound
local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://301964312"
sound.Looped = true
sound.PlaybackSpeed = 2
sound.SoundGroup = soundGroup

-- play the sound
sound:Play()

wait(10)

-- change the volume
soundGroup.Volume = 0.1 

wait(3)

-- return the volume
soundGroup.Volume = 0.5
 
wait(4)

-- add a sound effect
Instance.new("ReverbSoundEffect", soundGroup)