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

MarketplaceService not working?

Asked by 10 years ago

When I buy the first item, it doesn't change lds.PPK.Value. Any ideas why?

local MarketplaceService = Game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
    local numberBought = ds:IncrementAsync(playerProductKey, 1)
    for i,v in pairs (game.Players:GetChildren()) do
        if v.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == 20415462 then
                lds = v:FindFirstChild("Backpack")
                lds.PPK.Value = 50
                print(lds.PPK.Value)
                wait(10)
                lds.PPK.Value = 10
            elseif receiptInfo.ProductId == 20415479 then
                lds = v:FindFirstChild("Backpack")
                lds.PPK.Value = 125
                wait(10)
                aaaa = v:FindFirstChild('PlayerGui')
                lds.PPK.Value = 10
                aaaa.PowerUp:Destroy()
            elseif receiptInfo.ProductId == 20415500 then
                lds = v:FindFirstChild("Backpack")
                lds.PPK.Value = 500
                wait(15)
                aaaa = v:FindFirstChild('PlayerGui')
                lds.PPK.Value = 10
                aaaa.PowerUp:Destroy()
            elseif receiptInfo.ProductId == 20415510 then
                lds = v:FindFirstChild("Backpack")
                lds.PPK.Value = 2500
                wait(20)
                aaaa = v:FindFirstChild('PlayerGui')
                lds.PPK.Value = 10
                aaaa.PowerUp:Destroy()
            elseif receiptInfo.ProductId == 20120910 then
                lds = v:FindFirstChild("Backpack")
                game.ServerStorage.GreenSword:Clone().Parent = lds
            elseif receiptInfo.ProductId == 20121095 then
                lds = v:FindFirstChild("Backpack")
                game.ServerStorage.DCB:Clone().Parent = lds
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted 
end

Answer this question