Skip to content

Audio

The Audio API is used to create and play sounds. It will cache sounds when possible, to improve performance.

export type AudioProperties = {
Content: Content,
Name: string?,
Volume: number?,
RolloffStart: number?,
RolloffEnd: number?,
PlaybackRegion: NumberRange?,
TimePosition: number?,
Effects: {SoundEffect}?,
}

Specifies properties for creating a Sound instance.

export type PlayInTarget = BasePart | Attachment | SoundService | Folder

Creates a sound with the given properties.

NameTypeDefaultDescription
propertiesAudioPropertiesThe properties of the sound. Some additional properties will be set by default. Note that property names do not necessarily match the property name of the Sound Instance.

Sound

Plays a sound at the given vector position.

NameTypeDefaultDescription
referenceSoundSoundThe sound.
positionVector3The position to play the sound at.
noCloneboolean?If true, the provided sound instance will be used directly, instead of a clone being used.
toPlayer?A specific player to play the sound to. Must only be used on the server.

Plays a sound in the given instance. Sounds will be cached, unless specified otherwise.

NameTypeDefaultDescription
referenceSoundSoundThe sound.
instancePlayInTargetThe instance to play the sound in.
noCloneboolean?If true, the provided sound instance will be used directly, instead of a clone being used.
noCacheboolean?If true, the sound will not be cached.
toPlayer?A specific player to play the sound to. Must only be used on the server.

Plays a 2D sound. 2D sounds can be heard from everywhere. Sounds will be cached unless otherwise specified.

NameTypeDefaultDescription
referenceSoundSoundThe sound.
noCloneboolean?If true, the provided sound instance will be used directly, instead of a clone being used.
noCacheboolean?If true, the sound will not be cached.
toPlayer?A specific player to play the sound to. Must only be used on the server.

Plays a 2D sound. 2D sounds can be heard from everywhere. Sounds will be cached unless otherwise specified.

This function will correctly cache sounds accounting for the fact that maps are cloned when loaded. Maps should not use Audio.Play2D unless they disable caching.

NameTypeDefaultDescription
referenceSoundSoundThe sound.
mapFolderA folder in the map, or the map root itself.
noCloneboolean?If true, the provided sound instance will be used directly, instead of a clone being used.
noCacheboolean?If true, the sound will not be cached.
toPlayer?A specific player to play the sound to. Must only be used on the server.

Clears the cache for a specific reference sound. This must be used when a reference sound is modified, such as by changing the volume.

NameTypeDefaultDescription
referenceSoundSoundThe sound.