Help Needed: Script Breaks on Private Audio IDs

I’ve encountered a problem with my music queue system script where it fails to proceed to the next track when encountering a private audio ID. The GUI also freezes, and no subsequent public tracks will play. This issue started recently and seems to be a result of changes on Roblox’s end. I’ve attached a screenshot that illustrates the issue.

Script Behavior:

  • Normally, users can add songs to a queue via a TextBox.
  • The songs play in sequence, with the UI updating to show the current song and queue count.
  • However, if a private audio ID is submitted, the script and UI freeze.

here is the script

–local ScreenGui = script.Parent
local Frame = ScreenGui.MenuFrame
local TextBox = Frame.SongIdTextBox
local PlayButton = Frame.PlayButton
local NowPlayingTextBox = Frame.SongNameLabel
local QueueCountLabel = Frame.QueueCountLabel
local DurationLabel = Frame.TimeRemainingLabel

local currentSound = nil
local isPlaying = false
local waitingIDs = {}

local lastAddedTime = 0
local cooldown = 10

– Function to check if a new song can be added based on cooldown
local function puedeAgregarCancion()
local currentTime = os.time()
return currentTime - lastAddedTime >= cooldown
end

– Function to update the remaining duration of the current playing song
local function actualizarDuracionRestante(sound)
local duration = sound.TimeLength
local elapsedTime = sound.TimePosition
local remainingTime = duration - elapsedTime
DurationLabel.Text = “Restante: " … string.format(”%.2f", remainingTime) … “s”
end

– Main function to handle music playback
local function reproducirMusica()
if not puedeAgregarCancion() then
print(“Por favor espera antes de agregar otra canción.”)
return
end

lastAddedTime = os.time()

if isPlaying then
    local musicaID = TextBox.Text
    table.insert(waitingIDs, musicaID)
    TextBox.Text = ""
    QueueCountLabel.Text = "Canciones en cola: " .. tostring(#waitingIDs)
else
    local musicaID = TextBox.Text
    if tonumber(musicaID) then
        local sound = game.Workspace["DJ Table (Mini)"].Sound
        sound.SoundId = "rbxassetid://" .. musicaID
        currentSound = sound
        sound:Play()

        local nombreCancion = ""
        local success, error = pcall(function()
            nombreCancion = game:GetService("MarketplaceService"):GetProductInfo(musicaID).Name
        end)

        if success then
            NowPlayingTextBox.Text = "Now Playing: " .. nombreCancion
        else
            print("No se pudo obtener el nombre de la canción: " .. error)
        end

        isPlaying = true
        actualizarDuracionRestante(sound)

        while isPlaying and sound.IsPlaying do
            wait(1)
            actualizarDuracionRestante(sound)
        end

        currentSound = nil
        NowPlayingTextBox.Text = "Now Playing: None"
        isPlaying = false

        if #waitingIDs > 0 then
            local nextID = table.remove(waitingIDs, 1)
            TextBox.Text = nextID
            reproducirMusica()
        end

        QueueCountLabel.Text = "Canciones en cola: " .. tostring(#waitingIDs)
    else
        print("ID de música inválida")
    end
end

end

PlayButton.MouseButton1Click:Connect(reproducirMusica)–

any advice/suggestions are welcome

1 Like

Check this thread, I believe it has the solution you’re looking for.

I see, I will see how it is implemented in my system, thanks for the suggestion.

Sorry for the late response, I tried it and it didn’t work, for now I’m trying another alternative