SoundService

Show Deprecated
Not Creatable
Service

A service that determines various aspects of how Sounds play in the experience. SoundService is also often used to store SoundGroups, although this is not mandatory for groups to work.

SoundService properties such as AmbientReverb, DistanceFactor, DopplerScale and RolloffScale can be used to change how all Sounds play in the experience, and the SetListener() function allows you to set the position from where sounds are heard.

Code Samples

The code in this sample, when ran from a LocalScript, will change the SoundService.AmbientReverb property of SoundService when the player is inside a BasePart tagged using CollectionService.

To add or remove tags and reverb types, change the entries in the 'reverbTags' table.

Dynamic Reverb System

local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local SoundService = game:GetService("SoundService")
local localPlayer = Players.LocalPlayer
local reverbTags = {
["reverb_Cave"] = Enum.ReverbType.Cave,
}
-- collect parts and group them by tag
local parts = {}
for reverbTag, reverbType in pairs(reverbTags) do
for _, part in pairs(CollectionService:GetTagged(reverbTag)) do
parts[part] = reverbType
end
end
-- function to check if a position is within a part's extents
local function positionInPart(part, position)
local extents = part.Size / 2
local offset = part.CFrame:PointToObjectSpace(position)
return offset.x < extents.x and offset.y < extents.y and offset.z < extents.z
end
local reverbType = SoundService.AmbientReverb
while true do
task.wait()
if not localPlayer then
return
end
local character = localPlayer.Character
-- default to no reverb
local newReverbType = Enum.ReverbType.NoReverb
if character and character.PrimaryPart then
local position = character.PrimaryPart.Position
-- go through all the indexed parts
for part, type in pairs(parts) do
-- see if the character is within them
if positionInPart(part, position) then
-- if so, pick that reverb type
newReverbType = type
break
end
end
end
-- set the reverb type if it has changed
if newReverbType ~= reverbType then
SoundService.AmbientReverb = newReverbType
reverbType = newReverbType
end
end

Summary

Properties

Methods

Properties

AmbientReverb

Read Parallel

CharacterSoundsUseNewApi

Plugin Security
Read Parallel

DefaultListenerLocation

Plugin Security
Read Parallel

DistanceFactor

Read Parallel

DopplerScale

Read Parallel

RespectFilteringEnabled

Read Parallel

RolloffScale

Read Parallel

VolumetricAudio

Not Scriptable
Read Parallel

Methods

GetListener


Returns

OpenAttenuationCurveEditor

()
Plugin Security

Parameters

selectedCurveObjects: Instances

Returns

()

OpenDirectionalCurveEditor

()
Plugin Security

Parameters

selectedCurveObjects: Instances

Returns

()

PlayLocalSound

()

Parameters

sound: Instance

Returns

()

SetListener

()

Parameters

listenerType: Enum.ListenerType
listener: Tuple

Returns

()

Events