I'm not sure how to print out the audio name via sound Instance, I dunno if that's very clear but I thought i'd ask.
Here's how I've done it in the past
AudioName = game:GetService("MarketplaceService"):GetProductInfo(SONGIDHERE) print(AudioName.Name)
You can retrieve the audio name using get product info.
The function GetProductInfo of the MarketplaceService allows us to get information about an asset or product.
Example:-
local mpServ = game:GetService('MarketplaceService') local function getSongName(id) local res, data = pcall(function() return mpServ:GetProductInfo(id) end) -- check if the pcall was successful if res and data.AssetTypeId == 3 then return data.Name end -- either an error with finding the asset or its not a song return false end -- test data local songId = { -- a song id '142295308', -- not a song '193064098', '999999999999999999999999', -- another song '142281425' } -- run the tests for i=1, #songId do print(getSongName(songId[i])) end
The code above used pcall as the function GetProductInfo
will error if the id is not found.
Once the data has successfully been retrieved we also should check what the asset is using the data passed back ie AssetTypeId
. The Asset_type we need is audio so we need to compare this AssetTypeId
with 3 then pass back the name of the asset.
I hope this helps, please comment if you do not understand how / why this code works.