local remoteEvent = game.ReplicatedStorage.MusicQueue:WaitForChild("Queue")
local songqueue = {"rbxassetid://5712560018"}
local function queue(player, songid)
print(player.Name .. " fired the remote event")
table.insert(songqueue, "rbxassetid://" .. tostring(songid))
end
while true do
wait()
if (not game.SoundService.Music.Playing == true) then
if (not songqueue[1] == nil) then
game.SoundService.Music.SoundId = songqueue[1]
table.remove(songqueue, 1)
game.SoundService.Music.Playing = true
end
if (songqueue[1] == nil) then
game.SoundService.Music.SoundId = "rbxassetid://" .. tostring(5143383166)
game.SoundService.Music.Playing = true
end
end
end
remoteEvent.OnServerEvent:Connect(queue)
The script in ServerScriptService ^
For some reason, no matter what I do… I can’t get the queue to work. I’ve spent multiple hours trying to get this working, I don’t get any errors or warnings so that makes me even more clueless. Please help me
Hi maybe I figured It out, you have written (in server script): remote event.OnServerEvent:Connect(queue), after the loop (while true do)
I think that It hasn’t a connection with the local script because the server script hasn’t read that string.
local remoteEvent = game.ReplicatedStorage.MusicQueue:WaitForChild("Queue")
local songqueue = {}
remoteEvent.OnServerEvent:Connect(function(player,songid)
print(player.Name .. " fired the remote event")
table.insert(songqueue, "rbxassetid://" .. tostring(songid))
end)
while true do
wait()
if workspace.Music.Playing then
workspace.Music.Ended:Wait()
if songqueue[1] then
workspace.Music.SoundId = songqueue[1]
workspace.Music:Play()
workspace.Music.Ended:Wait()
table.remove(songqueue,1)
else
workspace.Music.SoundId = "rbxassetid://" .. tostring(5143383166)
workspace.Music:Play()
workspace.Music.Ended:Wait()
end
else
if songqueue[1] then
workspace.Music.SoundId = songqueue[1]
workspace.Music:Play()
workspace.Music.Ended:Wait()
table.remove(songqueue,1)
else
workspace.Music.SoundId = "rbxassetid://" .. tostring(5143383166)
workspace.Music:Play()
workspace.Music.Ended:Wait()
end
end
end -- also place your sound in workspace otherwise it won't work.