Garry's Mod Wiki

sound.Play

  sound.Play( string snd, Vector pos, number level = 75, number pitch = 100, number volume = 1, number dsp = 0 )

Description

Plays a sound from the specified position in the world. If you want to play a sound without a position, such as a UI sound, use surface.PlaySound instead.

This function is similar to EmitSound, but with less options.

Arguments

1 string snd
The sound to play. This should either be a sound script name (sound.Add) or a file path relative to the sound/ folder. (Make note that it's not sounds)
2 Vector pos
Where the sound should play.
3 number level = 75
Sound level in decibels. 75 is normal. Ranges from 20 to 180, where 180 is super loud. This affects how far away the sound will be heard, see SNDLVL enum.
4 number pitch = 100
The sound pitch. Range is from 0 to 255. 100 is normal pitch.
5 number volume = 1
Output volume of the sound in range 0 to 1.
6 number dsp = 0
The DSP preset for this sound. List of DSP presets

Example

Plays an explosion sound at the (0, 0, 0) map coordinates.

sound.Play( "ambient/explosions/exp1.wav", Vector(0, 0, 0) )