Garry's Mod Wiki

surface.PlaySound

  surface.PlaySound( string soundfile )

Description

Play a sound file directly on the client (such as UI sounds, etc).

Valid sample rates: 11025 Hz, 22050 Hz and 44100 Hz, otherwise you may see this kind of message:

Unsupported 32-bit wave file your_sound.wav and Invalid sample rate (48000) for sound 'your_sound.wav'

Arguments

1 string soundfile
The path to the sound file.
Currently does not work with sound scripts (sound.Add)

Issue Tracker: 4504

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)

Example

Plays a sound with a given name. The game will look for the file in following places in that order:

  • garrysmod/addons/myaddon/sound/mysound.wav
  • garrysmod/gamemodes/mygamemode/content/sound/mysound.wav
  • garrysmod/sound/mysound.wav
surface.PlaySound( "mysound.wav" )