Hi everyone. I have a bunch of local sound files that I am using for my game (temporarily, because I don't want to waste Robux on sounds). However, I want to detect if the file exists or not before loading it, so just in case, I can load a backup file stored on Roblox servers.
Other info: I am testing within Studio. I am testing with a LocalScript. This is a locally stored file and is not on the Roblox website The error is
Failed to load sound rbxasset://Sound.mp3: Unable to download sound data
I have tried using pcall() to change the SoundID, but that didn't work (LocalScript below, Sound.mp3 doesn't exist, the LocalScript is parented to a TextButton, and the Sound is parented to the same TextButton)
local BrokenSoundButton = script.Parent
local Sound = script.Parent.Sound
function TryBrokenSound()
pcall(PlayBrokenSound)
end
function PlayBrokenSound()
Sound.SoundId = "rbxasset://Sound.mp3"
Sound:Play()
end
BrokenSoundButton.MouseButton1Down:Connect(TryBrokenSound)
Edit: Answered my own question. You can use ContentProvider:PreloadAsync with Instances (not link to instances, unlike what the developer hub says) to detect whether it exists or not.
Edit 2: I love Scripting Helpers moderation. Totally not absolute garbage

2 comments
Bump
you need to upload the sound to roblox, can't do without