Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Anyway to detect existing local files?

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

0

Bump

0

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

1 answer

rbxassets are given IDs, not names , and your sound file name might not be the same as something uploaded to roblox.

However, roblox provides you with a way to search their database of already existing sounds on their website: https://www.roblox.com/develop/library?CatalogContext=2&SortAggregation=5&LegendExpanded=true&Category=9

You cannot use locally stored sound files. See https://developer.roblox.com/en-us/articles/Content for more information.

2 comments

0

These are locally stored files.Please see https://developer.roblox.com/en-us/articles/Content for more information

0

I updated my answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.