Music system not functioning correctly

You can write your topic however you want, but you need to answer these questions:

  1. I’m trying to make a music system. Keep it simple and clear!

  2. The issue is the first sound plays, but the second one does not. Include screenshots / videos if possible! The second sound does this https://gyazo.com/e00d16854594bb23a45a4d848c02393e

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to wait for the audio to load, but it just gets softlocked, so no matter what I do it doesn’t work, I’ve tried looking on devhub, nothing has really helped, and dev forum, no articles.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local soundtable = {5160230627,4734983736}
local songrequesttable = {}
local sound = Instance.new("Sound",game.Workspace)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local SongChange = ReplicatedStorage.SongChange
sound.Looped = false
while #songrequesttable == 0 do
for i,v in pairs(soundtable) do
		sound.SoundId = "rbxassetid://" .. v
	if not sound.IsLoaded then sound.Loaded:Wait() end
	SongChange:FireAllClients(v)
	sound:Play()
		sound.Ended:Wait()
		table.remove(soundtable,i)
	print("Song finished, swapping to next")
	end
end
while #songrequesttable >= 1 do
	for i,v in pairs(songrequesttable) do
	sound.SoundId = "rbxassetid://" .. v
	if not sound.IsLoaded then sound.Loaded:Wait() end
	SongChange:FireAllClients(v)
	sound:Play()
	sound.Ended:Wait()
	table.remove(songrequesttable,i)
	print("Song finished, swapping to next")
end
end
ReplicatedStorage.SongRequest.OnServerEvent:Connect(function(id)
	--add a prompt to make them buy a dev product--
	table.insert(songrequesttable,#songrequesttable + 1,id)
	print("test")
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Sorry if I annoy you devforum :C

It could be because your not waiting for the sound to loud. You can check if it’s loaded. If it isn’t loaded, you can wait for it to load.

local soundtable = {5047192759,4734983736}
local sound = Instance.new("Sound",game.Workspace)
sound.Looped = false
for i,v in pairs(soundtable) do
	sound.SoundId = "rbxassetid://" .. v
    if not sound.IsLoaded then sound.Loaded:Wait() end
	sound:Play()
	sound.Ended:Wait()
	print("Song finished, swapping to next")
end

@CY3REO Thank you so much, turns out I was just putting the wait in the wrong position, just goes to show, everything single line of code counts.

1 Like

added new stuff for like song request and now its broken again, with the same issue, and the song request isnt even working