How do I catch error code 46 (audio copyright)?

Studio updated and I can no longer seem to catch a specific loading error for sound.

I’m trying to check whether a user requested sound id throws an error due to the asset being subjected to copyright. In studio, this throws error code 46.
Failed to load sound rbxassetid://0000000001: error code 46

I’ve been trying to use pcall to catch this error, but wasn’t able to do so.
Take the following ID, for example:

local id = 5775859654
-- Link to the asset:
-- https://www.roblox.com/library/5775859654

local success, err = pcall(function()
    script.Parent.SoundId = ('rbxassetid://' .. id)
end)

if success then
    print('success', success)
else
    print('error', err)
end

The output is giving me:

success true - Server - Script:10
Failed to load sound rbxassetid://5775859654: error code 46 - Studio

2 Likes

the reason for this is because the player who created the audio is banned

The creator of the asset is Audio Generations, a group which has not been suspended.

You can try something like that

local succ, info = pcall(MarketplaceService.GetProductInfo, MarketplaceService, SongId)
if succ then
	if info.Name ~= "[ Content Deleted ]" or info.Name ~= "(Removed for copyright)" then
        --code here
    end
end

I know but the updater is banned and for this reason the audio is blocked since you can find a prohibited content in roblox

This wouldn’t work in all cases, including the example case in the OP. The info.Name would return ‘1932, Sheltered By The Stars, Dance Little Lady’. It’s also not a good practice to rely on asset names as even removed assets can still be altered after moderation.

Is there any way to error handle it though?

Regarding ''Error Code 46" this could solve the problem

although not very good practice on my game works as it should since moderate objects are given the same name

if that’s what @SonGoku6325 says, you could try to see if the player has been banned with some sort of check

You could watch for TimeLength to change to something that isn’t zero, however I’m unsure how well this will work since if I’m not wrong ROBLOX replaces copyrighted songs with placeholder songs.

Hello, you could use LogService to find the specific error.

game:GetService("LogService").MessageOut:Connect(function(a,b)
	if b == Enum.MessageType.MessageError then
		if string.find(a,"46") then
			warn("ERROR, LOG MESSAGE:\n"..a)
		end
	end
end)

This will find if the error has 46 in it, then print a warning.

You just need to change the string, currently its “46” which isn’t that ideal because if something prints 46, this will be triggered. You could try like sound or something unique.

(figured it out with @q_Fur )

1 Like

I had no idea LogService existed. Thank you for introducing me into a really handy tool for debugging.

I reckon if I filter for error code 46, it’ll be unique enough, right?

Yep, you just need to make sure that the error is actually an error (sounds kinda weird) but you don’t want to be looking for an error that never gets thrown. As long as the error has that text, it will be picked up.

1 Like