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 free-to-use audio can be searched for in the Toolbox.

  1. Click the Marketplace tab and select Audio from the menu.
  1. Click the button and then, in the Creator field, type ROBLOX. Select the first option to sort results by legal, free-to-use audio published by Roblox.
  1. Optionally, adjust the Sound Length range to more easily distinguish between short sound clips and longer background music tracks.
  1. Click the Apply button to save the sorting options.
  2. Back in the main panel, search for music by typing keywords into the search field.
  1. 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 item and select Copy Asset ID (this ID will be required for playback testing 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.

Length Cost
0–10 seconds 20
10–30 seconds 35
30 seconds – 2 minutes 70
2–7 minutes 350

To upload one or more audio files in .mp3 or .ogg format:

  1. Open the Asset Manager.
  1. Click the Import button.
  1. Select the audio file(s) you want to import from your local machine and confirm.
  2. In the File Import Cost popup, note the cost in Robux to upload the file(s). When ready, click the Confirm button.
  3. After the import process is complete, the audio item(s) will appear in the Audio folder.
  1. Right-click the item and select Copy ID to Clipboard (this ID will be required for playback testing below).

Playing Music

Playing background music can be achieved through scripting under two useful patterns as follows:

Audio Module

To set up multiple songs and play any of them on command, you can implement a basic audio module.

  1. In the Explorer window, add a new ModuleScript to ReplicatedStorage named AudioPlayer.
  1. In the script, delete all existing lines and paste in the following code:
  1. Create a new LocalScript inside StarterPlayerStarterPlayerScripts.
  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 8 (see Audio Marketplace or Uploading Custom Audio).
  1. Playtest the game and the track name specified on line 14 should play in the background.

Music Randomizer

To randomly shuffle background music, you can implement the following script which shuffles songs and avoids back-to-back repeats.

  1. In the Explorer window, create a new LocalScript inside StarterPlayerStarterPlayerScripts.
  2. Delete all existing lines and paste in the following code. If desired, specify different audio IDs starting on line 12 (see Audio Marketplace or Uploading Custom Audio).

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.

Positional 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 positional sounds and they share the following traits:

  • Volume — A positional 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.

If the source part/attachment already exists in a place, you can add a positional 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 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 just like background music using the audio module above.

GUI Sounds

Sound effects for interactive GUI objects can be played using the audio module 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 8.
  1. Playtest the game and you should hear the sound name specified on line 16 play when the button is activated.
Tags:
  • sound
  • music
  • audio
  • effects