Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Audio Script (Help?)

Making a game. I have SEVERAL audio scripts that are suppose to play a specific soundtrack after a certain amount of time, I have the sound grouped into the script.

Here is what the script is:

while true do wait(70) script.Music.Pitch = 1 script.Music:play()

end

I have the audio grouped into the script, not into the workspace, and most people would say, well just de-group the audio into workspace, but the only problem is that I have several music scripts, all the same, but different audio, so would it play all the soundtracks????

If anyone has ideas please help! :D

2 answers

So does each song have its own script? Say for example, you have 20 songs, each song has it's own script, so 20 scripts all grouped into a single model?

If that's the case, there's no way that going to work...unless each song in each script is wrapped in a function call that you can access from a common script. You could use something like the following (given each song is 70 seconds long):

local songAsset = {131154740,130797915,130776739}

function loadSound(soundName,assetNumber)

if (Workspace:FindFirstChild(soundName) == nil) or (soundName ~= newSound) then

	newSound = Instance.new("Sound")

	newSound.Name = soundName

	newSound.SoundId = "http://www.roblox.com/asset/?id="..assetNumber

	newSound.Parent = Workspace

	newSound.Volume = 1

end

newSound:Play()

end

function playSound()

local songName

for i, x in pairs(songAsset) do

	songName = "Song"..x

    print("Loading Sound: ", songName)

	loadSound(songName,x)	

	wait(70)

end

end

playSound()

Well you should like put while true do wait(70) script.Music.Pitch = 1 script.Music:play()

Before End The Game Dosen't Even Know what Sound too Play So Basiclly you need to ad something like while true do wait(70) script.Music.Pitch = 1 script.Music:play() id= Then the Id of the Sound Minus 1 at the End so OR Put a Sound Object() Well Actuailly put this Script into a sound script witht he Id of the Sound Minus 1 at the End so Like I am not a PRo Scripter But see fi it Helps.

end

This discussion is preserved as it was. New answers, comments, and votes are closed.