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

How would I detect if a soundid is invalid?

Asked by 6 years ago

I've tried tons of things to figure this out, but I can't seem to do it. I want to detect if the sound id is invalid so it will tell the user.

play.MouseButton1Click:connect(function()
    sound.SoundId = "rbxassetid://"..soundIdhere.Text
    sound.Playing = true
    Status.Text = "Song playing!"
end)

There's a snippet of the script.

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hi, Sharkeedub. The question you are asking has already been answered with great detail. I suggest you look into it for more in-depth answer.

How do I test whether a soundId in a script is valid?

Ad
Log in to vote
0
Answered by
Rawblocky 217 Moderation Voter
6 years ago
Edited 6 years ago

Use

game:GetService("MarketplaceService"):GetProductInfo(id).AssetTypeId==3

Basically, what it does is it will send "true" if it's an audio but "false" if it isn't

The id is from this: http://wiki.roblox.com/index.php?title=Asset_types You can add different ids for it, like for example, if you want only model ids, change the number "3" to the asset ID

Product infos: http://wiki.roblox.com/index.php?title=API:Class/MarketplaceService/GetProductInfo

Answer this question