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

How can I make a script which knows if an asset is invalid or deleted?

Asked by 6 years ago

I was trying to make a music player and thought of making a script that identifies an asset if it is valid, invalid, or not a sound ID, but it made me think "how can I find the results directly from the sound instance?" I researched and find no results. For now I haven't made a code. Does someone know an easy way to make a script which identifies asset id's presence and validity?

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

You could use MarketPlaceService:GetProductInfo() to find if the sound exists in the website library or not.

local mas = game:GetService('MarketplaceService')
local soundId = 0

local asset = mas:GetProductInfo(soundId)

if asset.Name ~= nil then
       print('exists')
else
       print("doesn't exist")
end
0
It works. Thanks! CrazyAceGaming0130 32 — 6y
Ad

Answer this question