Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Anyway to detect existing local files? [closed]

Asked by 3 years ago
Edited 3 years ago

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

0
Bump User#30567 0 — 3y
0
you need to upload the sound to roblox, can't do without Leamir 3138 — 3y

Closed as off-topic by SteamG00B, IAmNotTheReal_MePipe, Cynical_Innovation, and JesseSong

This question has been closed by our community as being off-topic from ROBLOX Lua Scripting.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
3 years ago
Edited 3 years ago

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.

0
These are locally stored files.Please see https://developer.roblox.com/en-us/articles/Content for more information User#30567 0 — 3y
0
I updated my answer. SteamG00B 1633 — 3y
Ad