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

How to make music play after a music?

Asked by 7 years ago
Edited 7 years ago

Okay the title seems complicated,but I will tell you explanation now! So how would I make that after the music stops playing it goes onto another one!And again,again,again and again.

Very noob at scripting but do I need to change something here?

local s = Instance.new("Sound")



s.Name = "Sound"

s.SoundId = "http://www.roblox.com/asset/?id=I know I put the ID here"

s.Volume = 0.1

s.Pitch = 1

s.Looped = true

s.archivable = false



s.Parent = game.Workspace



wait(0)



s:play()

wait(15)

local s = Instance.new("Sound")



s.Name = "Sound"

s.SoundId = "http://www.roblox.com/asset/?id=Again,I know I put the ID here!"

s.Volume = 0.1

s.Pitch = 1

s.Looped = true

s.archivable = false



s.Parent = game.Workspace



wait(0)



s:play()

I know I did two playing,but is that it?OR differently?

Please help!And Merry Christmas to all :D!!! Thank You!

2 answers

Log in to vote
0
Answered by 7 years ago

Merry Christmas (even though I don't celebrate this).

local s = Instance.new("Sound")

s.Name = "Sound"

s.SoundId = "http://www.roblox.com/asset/?id=I know I put the ID here"

s.Volume = 0.1

s.Pitch = 1

s.Looped = true

s.archivable = false

s.Parent = game.Workspace

wait(0)

s:play()

wait(1)

if not s.Playing==true then
    local s = Instance.new("Sound")

s.Name = "Sound"

s.SoundId = "http://www.roblox.com/asset/?id=Again,I know I put the ID here!"

s.Volume = 0.1

s.Pitch = 1

s.Looped = true

s.archivable = false

s.Parent = game.Workspace

wait(0)

s:play()

end

s:play()

That should do it.

Ad
Log in to vote
0
Answered by
thesit123 509 Moderation Voter
7 years ago

You should have a table that have all the sounds and its properties:

local Sounds = {
  Sound1 = {
    Name = "Name Here",
    Id = "http://www.roblox.com/asset/?id=I know I put the ID here",
  },
  Sound2 = {
    Name = "Name Here",
    Id = "http://www.roblox.com/asset/?id=I know I put the ID here",
  }
)

And make a loop that do of some what ElVolKo said.

while wait(0.01) do -- Loops over and over
  if SoundLocation:Playing ~= true then -- SoundLocation is for you to put where to Sound Object is located. Also this check if the music is playing.
    local SoundNumber = math.random(1, #Sounds) -- Select a random sound
    SoundLocation.Name = Sounds[SoundNumber][1] -- Put in the name
    SoundLocation.SoundId = Sounds[SoundNumber][2] -- Change the Id
    SoundLocation:Play()
  end
end

Putting it all together should be like this:

local Sounds = {
  Sound1 = {
    Name = "Name Here",
    Id = "http://www.roblox.com/asset/?id=I know I put the ID here",
  },
  Sound2 = {
    Name = "Name Here",
    Id = "http://www.roblox.com/asset/?id=I know I put the ID here",
  }
)

while wait(0.01) do
  if SoundLocation:Playing ~= true then -- SoundLocation is for you to put where to Sound Object is located.
    local SoundNumber = math.random(1, #Sounds)
    SoundLocation.Name = Sounds[SoundNumber][1] -- Put in the name
    SoundLocation.SoundId = Sounds[SoundNumber][2] -- Change the Id
    SoundLocation:Play()
  end
end

Answer this question