Getting 'Failed to load sound 0: Unable to download sound data' with this code

I’m getting an error in this script, I have ‘rbxassetid://’ then the ID, but it’s still not working. Sorry if it’s an easy fix, I’m new to coding.

The error is

Failed to load sound 0: Unable to download sound data

local assetService = game:GetService("ContentProvider")
local soundService = game:GetService("SoundService")

local songIds = {
	"rbxassetid://1845756489", -- Town Talk
	"rbxassetid://1843387153", -- Island Song
	"rbxassetid://1837879082" -- Paradise Fals

local player = game.Players.LocalPlayer

local soundCard ="Sound", soundService)
soundCard.Name = "Music"

local index = 0

while true do
	if index > #songIds then
		index = 0
	local currentSongId = songIds[index]
	soundCard.SoundId = index
	index = index + 1

Thanks in advance for the help!

Switch this to:

soundCard.SoundId = currentSongId
1 Like

That fixed that error, but I’m now getting:

Unable to assign property SoundId. Content expected, got nil

Ah, When you’re checking if the index is bigger than the amount of songs, Set it to 1 instead of 0. (And also set the index variable to 1 instead of 0)

1 Like

Thank you very much! It worked!

1 Like