Check if sound exists

I am making a music system where you can enter any song ID.

I ran into an error that my sound doesn’t exist. Anyone that knows so now I am looking for a method that is able to check if the ID exists?

I have taken a look on the forum but can’t really find something.

Thanks for the help!

local ID = 123456789

local MarketplaceService = game:GetService'MarketplaceService'
local Success, Response = pcall(MarketplaceService.GetProductInfo, MarketplaceService, ID)

if Success then
	if Response.AssetTypeId == Enum.AssetType.Audio.Value then
		print'ID exists'
	else
		print'Not an audio ID'
	end
else
	warn'ID doesn\'t exist'
end
5 Likes