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

How do I print a sound name and id?

Asked by 8 years ago

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

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

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

1local sound = //
2 
3CreateMessage("Now playing; ".. sound.Name .. " - " .. sound.SoundId
0
^^ I mean using httpservice, Not naming the Instance of the sound Id BadLuke1 2 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Using MarketplaceService:GetProductInfo.

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

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

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

01player.Chatted:connect(function(msg)
02    local info=getInfo(msg)
03    print(info.Name.."\n"..info.Description)
04 
05    --[[
06        in the output;
07        Doge
08Very hat. Such doge.  Wow.
09    ]]--
10 
11end)
0
Thanks SimplyRekt, But I tried that. I get an error; Can't Convert to JSON BadLuke1 2 — 8y
0
JSON? This code doesn't use JSON at all.. TheDeadlyPanther 2460 — 8y
0
Are you using it in a LocalScript? SimplyRekt 413 — 8y
0
I am trying to access the sound name.. So it says the sound name. BadLuke1 2 — 8y
View all comments (2 more)
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. BadLuke1 2 — 8y
0
I tried the same script and it worked. It works with any asset. SimplyRekt 413 — 8y

Answer this question