Help with Song queuing

I’ve made a series of posts today (and I’m kind of ashamed of it :joy:). Aside from that, I wish to receive help on how I could add songs to a queue using a table(using a remote event). The Client-Side part works fine, as it prints. However, It doesn’t work ServerSided. Anyone have any tips or errors that you can give/point out?

Serverside:

game.ReplicatedStorage.Events.SongEvent.AddSong.OnServerEvent:connect(function(plr,songid)
		table.insert(songs,2,songid)
		print("Song ID: "..songid.." queued!")
	end)

Clientside


script.Parent.MouseButton1Click:connect(function()
	repliactedstorage.Events.SongEvent.AddSong:FireServer(plr,script.Parent.Parent.Text.Text)
	print(plr.Name.." made song request: "..script.Parent.Parent.Text.Text)
end)

I’m aware I spelled replicated storage wrong, however It works so I left it alone.

On your table.insert, I believe you don’t need the 2. Since the song ID is a number.

The “2” is the number position in the table. He needs this to access the second spot in the table.

Client isn’t supposed to refer a player in the arguments. The serverside would think songid is a number, but it was an Instance. Connecting string and Instance would establish an error.

1 Like

So then would the problem lie with that each song after the first one being set, just replace the 2? And the second one wouldn’t move to the first slot?

Sorry, I had explained wrong. This is them adding the song two the second place on the table.

So how would I fix this? I’m kinda confused.

In the client side, it should be:

repliactedstorage.Events.SongEvent.AddSong:FireServer(script.Parent.Parent.Text.Text)

Remove plr.

1 Like

I tried that and it still doesn’t work. This is the ModuleScript that is receiving the server event:

game.ReplicatedStorage.Events.SongEvent.AddSong.OnServerEvent:connect(function(plr,songid)
		table.insert(songs,2,songid)
		print("Song ID: "..songid.." queued!")
	end)

Is there anything wrong with this?

I don’t see anything wrong with it. gl with your game!

1 Like

Can you reveal the processor that functions the queue? If you don’t have that, maybe that’s why your music system isn’t functioning.

What do you mean by processor? I just simply use a module script and when a player joins, 2 seconds later the music plays (the parent script calls the module). I’m not too sure what you mean by processor.

My music system works well but whenever I request something, only the Client Side responds not the ServerSide. So when I run my skip command the ID was never inserted into the table, so it was never queued.

@C4LEBS I would recommend using table.insert and table.remove for adding songs with GUI buttons if that’s what you are going for. By table.remove I meant for once the song is over.

I do use table.insert as shown here:

table.insert(songs,2,songid)

When the RemoteEvent is fired by the client, it’s supposed to send the song ID to the server and the song it is supposed to put it in second position.

By the way, it’s table.remove, not table.insert.

That’s the issue. Without me knowing the songs queue function (that processes every song added in the queue), I hardly would understand what your system is attempting to do, except the part that adds and prints out the newly added song id.

Sorry I said that wrong, I meant that it’s table.remove not table.delete

Oh, sorry if I made that unclear. Here is how the system plays:

local songs = {5215548352,1845167601,1842753530}
for i = 1, #songs do
			local song = songs[i]
			local songname = mps:GetProductInfo(song)
			songevent:FireAllClients(songname)
			music.SoundId = "rbxassetid://"..song
			music:Play()
			
			repeat wait() until music.IsPlaying == false
		end

That’s just the main part, this is where the player can add songs to the queue.

game.ReplicatedStorage.Events.SongEvent.AddSong.OnServerEvent:connect(function(songid)
		table.insert(songs,2,songid)
		print("Song ID: "..songid.." queued!")
	end)
1 Like