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

How to get in-game gear from Developer Products?

Asked by 9 years ago

I have a GUI Shop but I want people to buy things using Developers Products But I want them to buy a in-game gear that they get RIGHT when they buy it How do I do this?

1 answer

Log in to vote
0
Answered by
Traide -2
9 years ago

I don't know what your script looks like, but I have wrote a script for this situation.

productId = 19239712 -- You Dev Product ID here!

local MarketplaceService = Game:GetService("MarketplaceService")
function UsernameFromID(ID)
    if type(ID) ~= "number" then
    return
    end
    local sets = game:service("InsertService"):GetUserSets(ID)
    for k, v in next, sets do
        if v.Name == "My Models" then
            return v.CreatorName
        end
    end
end
function giveRewards(player)
       -- Put the function of you want to happen when bought here.
      -- Example; The line below gets the Sword from lighting, then puts it into the players backpack by cloning it.
    game.Lighting["Majestic Sword"]:Clone().Parent = player.Backpack
    return Enum.ProductPurcaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
    giveRewards(UsernameFromID(receiptInfo.PlayerId))
end
script.Parent.MouseButton1Down:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId)
end)
Ad

Answer this question