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 where it tells you the items name in-game?

Asked by 10 years ago

I know it has something to do with MarketPlaceService, but I dont know how to do it. :l

Smart Allec: English Please? What do you mean by that.

You know, how in Ryan's and Lua's admin when you do a commands like ;music or /music or musiclist it'll say the Name of the item in a Hint message.

1 answer

Log in to vote
0
Answered by 10 years ago

Try something like this:

function getItemName(itemId)
    local mps = Game:GetService("MarketplaceService") -- get marketplaceservice
    local item = mps:GetProductInfo(itemId) -- get the info about the product

    if(type(item) == "string") then
        --json, we need to decode it
        local Utils = assert(LoadLibrary("RbxUtility")) --Library we need to decode JSON
        item = Utils.DecodeJSON(item) -- turn it into a table
    end

    return item.Name -- not sure about this line, tell me if it errors
end
Ad

Answer this question