2 Sounds get played and not 1?

The question in the title, this is my script.

while true do
	local sound = game:GetService('SoundService')
	local soundMap = sound.Lobby:GetChildren()
	local soundChoose = soundMap[math.random(1, #soundMap)]
	local repStor = game:GetService("ReplicatedStorage")
	local musicEnabled = repStor:WaitForChild("Music")
	if musicEnabled.Value == true then
		soundChoose.Playing = true
		local length = soundChoose.TimeLength
		wait(length)	
	end
end

Every sound is listed in SoundService and every sound’s name =
Sound1
Sound2
Sound3
(You know what’s coming further)

Regards,
JailBreak2007_1

Maybe do this:

if musicEnabled.Value == true then
		soundChoose.Playing = true
		soundChoose.Ended:Wait()
	end

instead of

if musicEnabled.Value == true then
		soundChoose.Playing = true
		local length = soundChoose.TimeLength
		wait(length)	
	end
1 Like

You’d probably need to keep looping until the song chooses 2 different sounds:

while true do
	local sound = game:GetService('SoundService')
	local soundMap = sound.Lobby:GetChildren()
	local soundChoose = soundMap[math.random(1, #soundMap)]
    local soundChoose2 = soundMap[math.random(1, #soundMap)]
	local repStor = game:GetService("ReplicatedStorage")
	local musicEnabled = repStor:WaitForChild("Music")

	if musicEnabled.Value == true and soundChoose ~= soundChoose2 then
		soundChoose.Playing = true
		soundChoose2.Playing = true
		local length = soundChoose.TimeLength
		wait(length)	
	end
end