Attempting to add sound to my roblox game

im attempting to add audio to parts. does anyone know a single line way to do that?

2 Likes

using local sound = Instance.new("Sound") you can create a new sound and edit it’s properties by doing
sound.SoundId = "rbxassetid://yourid"

1 Like

It would take forever to explain everything myself, but here is the documentation link on sounds of you would like to read on that. A lot of the properties of a sound object are self-explanatory


To do specifically what you asked, you can add a sound into the part via script with Instance.new() or while you are in the editor, give it a sound ID, then you use sound:Play() to play the sound.

2 Likes

Here’s how you can do it:

Open Roblox Studio and create a new place or open an existing one.
In the Explorer window, select the Workspace folder.
Right-click in the workspace and select “Insert Object” from the context menu.
From the list of objects, select “Sound” and click “OK”.
In the Properties window, find the “SoundId” property and click the “Browse” button.
In the “SoundId” window, you can choose an audio file from your computer or select one from the Roblox library. You can also add a specific timestamp to start playing the audio from a certain point.
Once you have selected the audio file, you can adjust other properties such as “Volume” and “Pitch” to suit your needs.
You can then add the “Sound” object to your game by dragging it into the workspace or onto a specific part or object in the game.
You can use the “Sound” object to play different parts of the audio file using the “Play()” method and specifying the start and end times of the audio you want to play. For example, the following code will play the first 5 seconds of the audio file:

local sound = game.Workspace.Sound
sound.TimePosition = 0
sound:Play()
wait(5)
sound:Stop()

This code sets the “TimePosition” property of the “Sound” object to 0 (the beginning of the audio file), plays the audio, waits for 5 seconds, and then stops the audio playback. You can adjust the “TimePosition” property to play different parts of the audio file.

4 Likes

stop milking ChatGPT for free solutions lol.

11 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.