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

How do I print a sound name and id?

For instance, I am trying to make an addition in my script where I play a sound id, There will be a GUI at the top of the screen where it says the name of the song, and the Id of the song.. I can't find out any ways, it's getting frustrating.

Example

CreateMessage("Now playing; " .. Asset.Name .. " - " .. Asset.Id)

Help?

Thanks...

2 answers

If you use a Sound instance and name the relative sound with the respective sound asset and name you can do

local sound = //

CreateMessage("Now playing; ".. sound.Name .. " - " .. sound.SoundId

1 comment

0

^^ I mean using httpservice, Not naming the Instance of the sound Id

Using MarketplaceService:GetProductInfo.

GetProductInfo returns a table of the information of the asset provided. It's really easy to use;

function getInfo(id)
	local info=game:GetService("MarketplaceService"):GetProductInfo(id)
	return info
end

Now, all you have to do is call the function with the ID to get the info (like this);

player.Chatted:connect(function(msg)
	local info=getInfo(msg)
	print(info.Name.."\n"..info.Description)

	--[[
		in the output;
		Doge
Very hat. Such doge.  Wow.
	]]--

end)

6 comments

0

Thanks SimplyRekt, But I tried that. I get an error; Can't Convert to JSON

0

JSON? This code doesn't use JSON at all..

0

Are you using it in a LocalScript?

0

I am trying to access the sound name.. So it says the sound name.

0

I get the same error on local and nonlocal scripts... If you don't know what I mean, I am trying to make it so it gets the exact name from roblox and prints it into the ouput. I've seen it before.

0

I tried the same script and it worked. It works with any asset.

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