Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i put music on my game?

Asked by 10 years ago

i need it for my game

2 answers

Log in to vote
0
Answered by 10 years ago

When you're adding a sound, the first thing you want to do is preload it using ContentProvider so that it is ready when you come to play it. You then go on to create it as an Instance and edit the properties as you wish. Here is an example:

local SoundID = 1234567
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. SoundID)
local Sound = Instance.new("Sound", Workspace)
Sound.Volume = 1
Sound.SoundId = "http://www.roblox.com/asset/?id="..SoundID
Sound.Looped = false
Sound.Pitch = 1
Sound.Archivable = false
Sound:Play()

As you can see, I start off by creating a new variable called SoundID. This is not required but I find that it makes the code look neater, and I prefer it this way. Then we I use ContentProvider to preload it with the default roblox asset string concatenated with the SoundID at the end. Then I create the actual Sound instance and adjust all the properties, and finally I use the Play method on it. You know it's a method because of the fact that it starts with colons and ends with two brackets. You can adjust this as you wish, make the volume lower, pitch higher, etc.

I hope this helped!

Ad
Log in to vote
-1
Answered by 10 years ago

First of all, you need a sound. So when you find a sound you need to do this. Insert a script and then SoundService inside of it (Insert>SoundService) Then put the sound ID inside the SoundService make sure to use gameasset.

So your script should look something like this.

local Sound = game.Script.SoundService

Sound.Play()

If you want it to loop your script should look like this.

while true do
local Sound = game.Script.SoundService

Sound.Play()
0
That is completely wrong. Archonious2 160 — 10y

Answer this question