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

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

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

✓ Accepted answer

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.

5 comments

0

Yeah pretty much the same as mine :p

0

xD, though I posted mine first.

0

use a loop

0

How would I loop this?

0

add while true do

-- 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.

1 comment

0

Thank you both for you answers!

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