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

Doesn't prompt a buy?

Asked by
wackem 50
8 years ago

1st Question: The following code doesn't prompt a purchase and then give them the credits

Normal Script:

local MarketPlace = game:GetService("MarketplaceService")
local DataStore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local Product = 24670894
MarketPlace.ProcessReceipt = function(ReceiptInfo)
        for i, Player in ipairs(game.Players:GetChildren()) do
                if Player.userId == ReceiptInfo.PlayerId then
                        if ReceiptInfo.ProductId == Product then
                                -- edit from here
                                Player.leaderstats.Credits.Value = Player.leaderstats.Credits.Value + 50
                                -- to here
                        end
                end
        end
local PlayerProductKey = "player_" .. ReceiptInfo.PlayerId .. "_purchase_" .. ReceiptInfo.PurchaseId
return Enum.ProductPurchaseDecision.PurchaseGranted
end

Local Script (in an imagebutton):

local Product = 24670894 -- change id to your product, remember to do the same in the main one too
local MarketPlace = game:GetService("MarketplaceService")
script.Parent.MouseButton1Down:connect(function(Player)
        MarketPlace:PromptProductPurchase(game.Players.LocalPlayer, Product)
end)

Answer this question