MusicID script doesnt work

im guessing its something pretty simple that im missing, but basically i have a text button and when you type a soundID in it should play the desired audio, however i get the same error: Failed to load sound 12222030: Unable to download sound data this is the script so far (im 70% sure im just missing something):

local pGui = game.Players.LocalPlayer.PlayerGui
local MusicUI = pGui:WaitForChild("Music")
local MusicBox = MusicUI.TextBox

local SoundToPlay = Instance.new("Sound")
SoundToPlay.Parent = game:GetService("SoundService")

MusicBox.FocusLost:Connect(function(enterpressed)
	if enterpressed then
		SoundToPlay.SoundId = MusicBox.Text
		SoundToPlay:Play()
		
		task.wait(1)
		MusicBox.Text = "TYPE MUSIC ID"
	else
		MusicBox.Text = "TYPE MUSIC ID"
	end
end)
2 Likes

Did you try entering the rest of the link before entering the id?

Example:
“rbxassetid://” … MusicBox.Text

2 Likes

that was quick, knew i was missing something so simple

on the side, how could i detect if it couldnt load an audio? for example, the requested audio was banned?

I dont know how to do that, though there is this article