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

Purchase Script Does Not Prompt Me To Purchase It?

Asked by 7 years ago
Edited 7 years ago

I made a script so I don't have to update the game everyday to put up a new gift for the game to sell to players. I tested it myself (Deleted the gift and joined the game) but it did not prompt me to buy the free gift. Can someone help? [The gift is onsale]

game.Players.PlayerAdded:connect(function(plr)
    if not game.MarketplaceService:PlayerOwnsAsset(plr,582409069) then
        local passStats = game.MarketplaceService:GetProductInfo(582409069)
        if passStats.IsForSale then
            game.MarketplaceService:PromptPurchase(plr,582409069)
        end
    end
end)

EDIT : The gift is a decal asset. So someone from the ROBLOX Discord suggested that I should use print to find out where the code doesn't work. I found out that it was on the passStats.IsForSale. It returned to false, even though the asset was onsale. Please help.

2 answers

Log in to vote
0
Answered by 7 years ago

Decals can't be put up on sale (as in they can't be purchased using ROBUX), which is why IsForSale is returning false.

To fix this, you'll want to use IsPublicDomain instead of IsForSale since the decal can be added to the player's inventory without buying it.

game.Players.PlayerAdded:connect(function(plr)
    if not game.MarketplaceService:PlayerOwnsAsset(plr,582409069) then
        local passStats = game.MarketplaceService:GetProductInfo(582409069)
        if passStats.IsPublicDomain then --If the decal can be added to the user's inventory, prompt them to "purchase" it.
            game.MarketplaceService:PromptPurchase(plr,582409069)
        end
    end
end)

See here for more information.

Ad
Log in to vote
0
Answered by 7 years ago

If you created the item you must include "Enum.InfoType.Product" as your second argument for :GetProductInfo() as mentioned in the Wikipedia.

0
Still doesn't work. It said an error "MarketplaceService.GetProductInfo() failed because rawProductInfo was empty" PlantChampion 136 — 7y
0
The wiki said Enum.InfoType.Product is only used on Developer Products. This isn't a developer product but a decal (which is an asset) PlantChampion 136 — 7y

Answer this question