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

Dev product not working? Am I missing something?

Asked by
yurhomi10 192
10 years ago
--SET UP VARIABLES--

local MarketPlace = game:GetService("MarketplaceService")
local Datastore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
DamageID = 19312506

--------------------

script.Parent.MouseButton1Down:connect(function()
MarketPlace.ProcessReceipt = function(receiptinfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptinfo.PlayerId then

            if receiptinfo.ProductId == DamageID then
                player.Character.Humanoid.Health = player.Character.Humanoid.Health - 20
                script.Parent.Text = player.Name .. " has bought death ! "
            end
        end
    end
    local productplayerkey = "player_" .. receiptinfo.PlayerId .. "_purchase_" .. receiptinfo.PurchaseId
    DataStore:IncrementAsync(productplayerkey, 1)

    return Enum.ProductPurchaseDecision.PurchaseGranted
end
end)

1 answer

Log in to vote
1
Answered by
jav2612 180
10 years ago

I'm having a similar problem but I believe I know how to fix this. I'm pretty sure that the ProcessReceipt function should be in a separate script somewhere. Your going to need to use PromptProductPurchase(player, ID) instead of simply calling the Receipt function when the player pushes the button.

0
Hm.. alright, thanks. just not sure how to exactly make this work.. yurhomi10 192 — 10y
0
put script.Parent.MouseButton1Down:connect(function() PromptProductPurchase(player, ID) end) in the button, and then use the ProcessReceipt function chunk in a separate script in the Workspace. jav2612 180 — 10y
Ad

Answer this question