Audio
The Audio API is used to create and play sounds. It will cache sounds when possible, to improve performance.
AudioProperties
Section titled “AudioProperties”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.
PlayInTarget
Section titled “PlayInTarget”export type PlayInTarget = BasePart | Attachment | SoundService | FolderFunctions
Section titled “Functions”MakeSound
Section titled “MakeSound”Creates a sound with the given properties.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
properties | AudioProperties | The 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. |
Returns
Section titled “Returns”Sound
PlayAt
Section titled “PlayAt”Plays a sound at the given vector position.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
referenceSound | Sound | The sound. | |
position | Vector3 | The position to play the sound at. | |
noClone | boolean? | If true, the provided sound instance will be used directly, instead of a clone being used. | |
to | Player? | A specific player to play the sound to. Must only be used on the server. |
PlayIn
Section titled “PlayIn”Plays a sound in the given instance. Sounds will be cached, unless specified otherwise.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
referenceSound | Sound | The sound. | |
instance | PlayInTarget | The instance to play the sound in. | |
noClone | boolean? | If true, the provided sound instance will be used directly, instead of a clone being used. | |
noCache | boolean? | If true, the sound will not be cached. | |
to | Player? | A specific player to play the sound to. Must only be used on the server. |
Play2D
Section titled “Play2D”Plays a 2D sound. 2D sounds can be heard from everywhere. Sounds will be cached unless otherwise specified.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
referenceSound | Sound | The sound. | |
noClone | boolean? | If true, the provided sound instance will be used directly, instead of a clone being used. | |
noCache | boolean? | If true, the sound will not be cached. | |
to | Player? | A specific player to play the sound to. Must only be used on the server. |
Play2DMap
Section titled “Play2DMap”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.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
referenceSound | Sound | The sound. | |
map | Folder | A folder in the map, or the map root itself. | |
noClone | boolean? | If true, the provided sound instance will be used directly, instead of a clone being used. | |
noCache | boolean? | If true, the sound will not be cached. | |
to | Player? | A specific player to play the sound to. Must only be used on the server. |
InvalidateCache
Section titled “InvalidateCache”Clears the cache for a specific reference sound. This must be used when a reference sound is modified, such as by changing the volume.
Parameters
Section titled “Parameters”| Name | Type | Default | Description |
|---|---|---|---|
referenceSound | Sound | The sound. |