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

Dev Product Reciept Not Working? [closed]

Asked by
TofuBytes 500 Moderation Voter
10 years ago

I put a regular script into the Starterpack. (Unsure if this is the problem.) I'm trying to send leaderstats NumberValue "Coins". Purchasing works, but sending the "Coins" won't. Any help on how to fix this?

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

MarketplaceService.ProcessReceipt = function(receiptInfo)
    print("Testing Receipt Loaded")
    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 == 19918045 then
                print("Did this succeed?")


                lds = v:FindFirstChild("leaderstats")
                if lds ~= nil then
                    cs = lds:FindFirstChild("Coins") 
                    if cs ~= nil then
                        cs.Value = cs.Value + 100
                        print("Coins Sent") 
                    end
                end
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Locked by Thewsomeguy, adark, and Articulating

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by 10 years ago

The normal script should go into ServerScriptStorage or Workspace (or somewhere that it won't be cloned like it does in the Backpack)

0
It works! Thank you! TofuBytes 500 — 10y
Ad