Sound
Plays audio from a URL, either everywhere or from a spot in the world.
- Inherits: Instance
- Creatable: Yes:
new Sound(), orInstance.new('Sound', parent). - Replication: Replicated: clients get a copy, and changes the server makes reach them.
Sounds play on players’ devices. A Sound is only heard while it’s in the Workspace or inside the local player (for example in their PlayerGui); anywhere else it’s silent. Directly inside a BasePart it comes from the part and fades with distance; elsewhere it plays at the same volume everywhere.
Setting playing (or calling play()) on the server plays the sound for everyone; doing it in a
LocalScript plays it for that player only. Browsers block audio until the player first clicks or
presses a key: a sound that isn’t looped and starts before that is skipped, and looped sounds
start then. When a sound that isn’t looped finishes, playing turns false on that device.
Properties
Section titled “Properties”soundUrl
Section titled “soundUrl”Type: string · Default: '' · Access: read/write · Replicates: yes
URL of the audio file (a format the browser can play, such as MP3, OGG or WAV). Players’ devices download it; if one can’t, a warning goes to the game’s output.
volume
Section titled “volume”Type: number · Default: 0.5 · Range: 0 to 10 (clamped) · Access: read/write · Replicates: yes
Loudness: 0 is silent and 1 is the file’s own volume; higher values amplify.
looped
Section titled “looped”Type: boolean · Default: false · Access: read/write · Replicates: yes
Starts over at the end instead of stopping.
playing
Section titled “playing”Type: boolean · Default: false · Access: read/write · Replicates: yes
Set true to play (or call play()).
Set it to false to stop the sound.
playbackSpeed
Section titled “playbackSpeed”Type: number · Default: 1 · Range: 0.1 to 4 (clamped) · Access: read/write · Replicates: yes
Playback rate: 2 plays twice as fast (and higher), 0.5 half as fast.
Inherited from Instance: name, archivable, id, className, parent, destroyed
Methods
Section titled “Methods”play(): voidPlays the sound from the start, restarting it if it’s already playing.
stop(): voidStops the sound.
Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”A bell that rings when touched
Section titled “A bell that rings when touched”import { Character, Part, Sound, getChild, workspace } from '@rally/sdk';
const bell = getChild(workspace, 'Bell', Part);const ding = getChild(bell, 'Ding', Sound); // inside the part, so it's heard from the bellbell.touched.connect((other) => { if (other instanceof Character) ding.play();});