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
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
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.
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.
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.