Failed to load sound rbxassetid://<assetid>: Unable to download sound data
in the console. Is there a way to detect when this happens through scripts?
I tried checking Sound.IsLoaded but that sometimes gets it wrong because sounds take time to load, and if you don’t wait long enough it might produce a false-positive.
the problem is I don’t always know how long it will take for the sound to load
the speeds that sounds load can be affected by internet speed for example
That will say “Could not find audio asset” if you didn’t set it up using AudioPlayer.setupAudio, but if you did set it up and the asset fails to load (for example if it was content deleted) it will just wait forever
Basically i need to be able to know when it’s going to wait forever and stop
You could try using a loop to check if the sound is loaded or not using a timer that counts up for every second that IsLoaded is false.
local Sound = YourSoundHere --Change this to where your sound is
local LoadTimeout = 120 --This is how long the script will give for the sound to load in seconds until assuming it has failed (2 minutes should be long enough, right?)
local LoadTime --Just declaring this variable since we will use it later...
repeat
LoadTime = LoadTime + 1
wait(1)
until Sound.IsLoaded == true or LoadTime == LoadTimeout
If LoadTime == LoadTimeout then
print("Sound probably has failed to load, timeout reached!")
else
print("Sound loaded successfully!")
end