Sounds and Music
Sounds and Music
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.
A wide array of free-to-use audio can be searched for in the Toolbox.
- Click the Marketplace tab and select Audio from the menu.
- 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.
- Optionally, adjust the Sound Length range to more easily distinguish between short sound clips and longer background music tracks.
- Click the Apply button to save the sorting options.
- Back in the main panel, search for music by typing keywords into the search field.
- 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).
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.
|30 seconds – 2 minutes||70|
To upload one or more audio files in .mp3 or .ogg format:
- Open the Asset Manager.
- Click the Import button.
- Select the audio file(s) you want to import from your local machine and confirm.
- In the File Import Cost popup, note the cost in Robux to upload the file(s). When ready, click the Confirm button.
- After the import process is complete, the audio item(s) will appear in the Audio folder.
- Right-click the item and select Copy ID to Clipboard (this ID will be required for playback testing below).
Playing background music can be achieved through scripting under two useful patterns as follows:
To set up multiple songs and play any of them on command, you can implement a basic audio module.
- In the Explorer window, add a new
ModuleScriptto ReplicatedStorage named AudioPlayer.
- In the script, delete all existing lines and paste in the following code:
- Create a new
LocalScriptinside StarterPlayer → StarterPlayerScripts.
- Playtest the game and the track name specified on line 14 should play in the background.
To randomly shuffle background music, you can implement the following script which shuffles songs and avoids back-to-back repeats.
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.
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:
- In the Explorer window, insert a new
Soundobject as a child of the source object.
- 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.
- Toggle its Playing property on (sounds do not play automatically, so you must explicitly tell them to start playing).
- Playtest the game and observe the sound’s qualities based on your character’s proximity to the source.
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.
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.
- 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.
- Select the new button and insert a
- 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.
- Playtest the game and you should hear the sound name specified on line 16 play when the button is activated.