PcoWSkbVqDnWTu_dm2ix

10 min

While building a game, it’s easy to overlook the importance of sounds and music. Combined creatively, these can set an atmospheric or exciting tone, build suspense, and bring life to your game’s characters.

Audio Marketplace

A wide array of audio can be searched for in the Toolbox by clicking the Marketplace tab and selecting Audio from the menu.

Within the view, you can search by name or click the button to:

  • Search by Creator (the Roblox user who published the file).
  • Search by Sound Length to more easily distinguish short sound effects from longer music tracks.
  • Sort audio by relevance, most frequently taken, number of “favorite” votes, most recently updated, or highest rated.

Audio can be previewed directly within Studio by clicking the play button in the corner of each listing. Once you locate an audio file to use, right-click the listing and select Copy Asset ID (this ID will be required for playback testing in the sections below).

1. Preview
2. Right-click and copy ID

Uploading Custom Audio

On Roblox, uploading audio files comes at a small cost in Robux — this accounts for the time it takes moderators to review every sound file that users upload.

To upload audio on the Roblox site:

  1. Visit the Create Audio page where you’ll be prompted to upload a local file and give it a name. Audio files must be .mp3 or .ogg format, shorter than 7 minutes, and smaller than 19.5 MB.
  2. Click the Estimate Price button. The cost to upload an audio file is based on the following pricing structure:
Length Cost
0–10 seconds 20
10–30 seconds 35
30 seconds – 2 minutes 70
2–7 minutes 350
  1. Click the Purchase button to upload the audio file.
  2. Once the file is uploaded, it will appear in the list on the page. Click the name to open its dedicated page and copy/record its numeric ID from the URL in the browser window (this ID will be required for playback testing in the sections below).

Playing Music

Playing background music in a game can be accomplished via scripting, as follows:

  1. In the Explorer window of Studio, add a new ModuleScript to ReplicatedStorage.
  1. Rename the new script AudioPlayer.
  1. In the script, delete all existing lines and paste in the following code:
  1. Create a new LocalScript inside StarterPlayerScripts (a child of StarterPlayer).
  1. In the script, delete all existing lines and paste in the following code. If desired, input different track names and audio IDs starting on line 9 (see Audio Marketplace or Uploading Custom Audio above).
  1. Playtest the game and you should hear the track name specified on line 14 playing in the background.

Playing Sounds

Unlike background music, sounds will often originate from a specific place or object inside the game — the engine of a vehicle, the battle cry of an enemy, etc. However, they may also be played as an “ambient” sound like wind blowing or rain falling.

3D Sounds

A sound placed in a BasePart or an Attachment will emit its sound from the part’s BasePart/Position|Position or the attachment’s Attachment/WorldPosition|WorldPosition. These are considered 3D sounds and they share the following traits:

  • Volume — A 3D sound will play louder as a player gets closer to its source.
  • Stereo — If one side of a player is closer to the sound’s source, the player’s corresponding speaker will be louder.
  • Doppler Effect — If the source of a 3D sound is approaching a player, it will play at a higher pitch. Similarly, it will play at a lower pitch if the source is traveling away from the player.

If the source part/attachment already exists in a place, you can add a 3D sound directly within Studio:

  1. In the Explorer window, insert a new Sound object as a child of the source object.
  1. Select the new sound object and, in the Properties window, locate its SoundId property. Enter rbxassetid:// followed by a valid audio ID, for instance rbxassetid://1847352423.
  1. Toggle its Playing property on (sounds do not play automatically, so you must explicitly tell them to start playing).
  1. Playtest the game and observe the 3D sound’s qualities based on your character’s proximity to the source.

Ambient Sounds

Ambient environmental sounds like wind and thunder don’t need to be attached to a part because they come from all around the player. As such, these type of sounds can be played using the same scripts shown in Playing Music above.

GUI Sounds

Sound effects for interactive GUI objects can be played using the same ModuleScript shown in Playing Music above. Instead of playing a sound immediately, however, you can hook it up to the GuiButton/Activated|Activated event listener for the button.

  1. In StarterGui, add a new ScreenGui, then create a new TextButton within it. If you’re unfamiliar with buttons and their basic options, see articles/Creating GUI Buttons|Creating GUI Buttons.

  2. Select the new button and insert a LocalScript.

  1. In the script, delete all existing lines and paste in the following code. If desired, input a different sound name and audio ID on line 9.
  1. Playtest the game and you should hear the sound name specified on line 17 play when the button is activated.
Tags:
  • sound
  • music
  • audio
  • effects