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

I'm trying to get 3 audios to play I thought I had it, can someone help?

Asked by 7 years ago

I'm trying to get 3 audios to play on a loop but only one plays I thought I had it, can someone help?

Music Script (not sure whats wrong)

local sound = Instance.new("Sound", workspace)
sound.Volume = .05


wait(5)
sound.SoundId = "rbxassetid://"..536215322
sound:Play()
sound.Ended:Wait()
sound:Destroy()
wait(.05)
sound.SoundId = "rbxassetid://"..852278165
sound:Play()
sound.Ended:Wait()
sound:Destroy()
wait(.05)
sound.SoundId = "rbxassetid://"..531211690
sound:Play()
sound.Ended:Wait()
sound:Destroy()
wait(.05)

Thanks for your time

-Species

2 answers

Log in to vote
0
Answered by 7 years ago

You will have to create 3 sound objects or else it would just switch the sounds. Also, you are destroying sound so you can't play it anymore.

try this code;

local sound1 = Instance.new('Sound', game.Workspace)
sound1.Volume = 0.05

local sound2 = Instance.new('Sound', game.Workspace)
sound1.Volume = 0.05

local sound3 = Instance.new('Sound', game.Workspace)
sound1.Volume = 0.05

wait(5)
sound1.SoundId = "rbxassetid://"..536215322
sound1:Play()
sound1.Ended:Wait()
sound1:Destroy() --Where u destroyed a sound
wait(0.05)
sound2.SoundId = "rbxassetid://"..852278165
sound2:Play()
sound2.Ended:Wait()
sound2:Destroy() --Where u destroyed a sound
wait(0.05)
sound3.SoundId = "rbxassetid://"..531211690
sound3:Play()
sound3.Ended:Wait()
sound3:Destroy() --Where u destroyed a sound

By creating 3 new sounds, all your problems are solved. If this helped then please accept answer.

0
Yeah pretty much the same as mine :p shakran 23 — 7y
0
xD, though I posted mine first. BlackOrange3343 2676 — 7y
0
use a loop User#5423 17 — 7y
0
How would I loop this? Unkn0wn_Species 20 — 7y
0
add while true do BlackOrange3343 2676 — 7y
Ad
Log in to vote
0
Answered by
shakran 23
7 years ago
-- initializing 3 audio instead of just 1
local sound1 = Instance.new("Sound", workspace)
local sound2 = Instance.new("Sound", workspace)
local sound3 = Instance.new("Sound", workspace)
sound1.Volume = .05
sound2.Volume = .05
sound3.Volume = .05
wait(5)
sound1.SoundId = "rbxassetid://"..536215322
sound1:Play()
sound1.Ended:Wait()
sound1:Destroy()
wait(.05)
sound2.SoundId = "rbxassetid://"..852278165
sound2:Play()
sound2.Ended:Wait()
sound2:Destroy()
wait(.05)
sound3.SoundId = "rbxassetid://"..531211690
sound3:Play()
sound3.Ended:Wait()
sound3:Destroy()
wait(.05)

Now it should work. The thing is that you created only 1 audio instance and you destroyed that the moment the first audio stopped playing. This should work but if you want to make it shorter you can just make one sound audio and change the id the moment the song ends. Then play it right after inputting the next id.

0
Thank you both for you answers! Unkn0wn_Species 20 — 7y

Answer this question