How do I add and play sounds for when it starts after the countdown? Also I wanted to know how do I add songs to some of them, like the first three would be bruno mars songs, and the other ones would be gangnam style song. And when it is done, the countdown starts over and does the same. Just like this script, but with sounds. How do I do it? This is the script (Thank you BlueTaslem):
local bin = script.Parent local decal = bin.Decal local MainSlides = { {'http://www.roblox.com/asset/?id=213163470', 15}, {'http://www.roblox.com/asset/?id=213486920', 3}, {'http://www.roblox.com/asset/?id=157656296', 3}, {'http://www.roblox.com/asset/?id=213486967', 3}, {'http://www.roblox.com/asset/?id=151111211', 3}, {'http://www.roblox.com/asset/?id=213487020', 3} } function getNumTabs(tab) local num = 0 for i,v in pairs(tab) do num = num + 1 end return num end function runTable(tab) for i = 1,getNumTabs(tab) do local currentTab = tab[tostring(i)] decal.Texture = currentTab[1] wait(currentTab[2]) end end -- (Define everything needed for runTable here, of course) local c = game.Workspace.Countdown.SurfaceGui.TextLabel function countDown() for timeLeft = 20, 0, -1 do -- Replaces the 40 lines of repetition! c.Text = timeLeft wait(1) end c.Text = "Movie has started!" end while true do countDown() runTable(MainSlides) end
You can use Instance.new()
to make a sound. Then you can change the sound ID and volume. I created a table where you could pick a random song from. It's completely random. It plays the song then destroys it after.
local bin = script.Parent local decal = bin.Decal local MainSlides = { {'http://www.roblox.com/asset/?id=213163470', 15}, {'http://www.roblox.com/asset/?id=213486920', 3}, {'http://www.roblox.com/asset/?id=157656296', 3}, {'http://www.roblox.com/asset/?id=213486967', 3}, {'http://www.roblox.com/asset/?id=151111211', 3}, {'http://www.roblox.com/asset/?id=213487020', 3} } SongIDs = {"http://www.roblox.com/asset/?id=130844430", "http://www.roblox.com/asset/?id=150109580", "http://www.roblox.com/asset/?id=138310274", "http://www.roblox.com/asset/?id=151758509"} --Add song IDs Here. function getNumTabs(tab) local num = 0 for i,v in pairs(tab) do num = num + 1 end return num end function runTable(tab) for i = 1,getNumTabs(tab) do local currentTab = tab[tostring(i)] decal.Texture = currentTab[1] wait(currentTab[2]) end end -- (Define everything needed for runTable here, of course) local c = game.Workspace.Countdown.SurfaceGui.TextLabel function countDown() local song = Instance.new("Sound", bin) --Second argument is the parent. song.SoundId = SongIDs[math.random(1,#SongIDs)] --Choose a random song song.Volume = 0.5 --Volume is 0.5 song.Pitch = 1 --Pitch = 1 --Don't touch unless you want to make it a little higher or lower. song:Play() --Play Song for timeLeft = 20,0,-1 do c.Text = timeLeft wait(1) end c.Text = "Movie has started!" song:Destroy() end while true do countDown() runTable(MainSlides) end
All you would need to do for this particular code is to add new song Assets into the list.
To get an assetID, you need to find the sound you want in the Catalog, copy its ID in the URL of the page, and then subtract one from the ID to find its assetID.
For example, if I found a sound that I liked, and its ID was 347814
, I would subtract one to find its assetID. The assetID of this would be 347813
.
Then, all you would need to do is add the assetID to the end of http://www.roblox.com/asset/?id=
. Therefore, the line you would have is 'http://www.roblox.com/asset/?id=347813
.
Lastly, you would add it into the table in the code just like he has done. Create a new line of code underneath line 10, and insert this:
{'http://www.roblox.com/asset/?id=347813', 3}
And two more things, you would have to add a comma at the end of line 10. Also, the 3
is just the length of the music, I believe.
Obviously, you wouldn't use 347813, you would find your own assetID.
Hope this helped!