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

How to properly use Developer Products?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

I've been having some trouble with this over time. My problem is that someone could press Cancel (On the GUI Prompt to purchase the Developer Product) and 5 minutes later, they'd get the product. On other occasions, people would properly purchase the Developer Product, but they wouldn't receive an item. They would need to purchase it again. If I test the script in a server by myself, it would appear to work without any flaws. Does anybody have any pointers? Any help in advance is appreciated.

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

game.Players.PlayerAdded:connect(function()
    print("start")
local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage()
for _, DevProductContainer in pairs(DeveloperProducts) do
    for Field, Value in pairs(DevProductContainer) do
        print(Field .. ": " .. Value)
    end
    print(" ")
end
print("end")
end)

MarketplaceService.ProcessReceipt = function(receiptInfo) 
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == productId then
                for i,v in pairs(player.Order:GetChildren()) do
                    if v:IsA("BoolValue") then
                        game.Lighting[v.Name]:clone().Parent = player.Backpack
                    end
                end
                player.Order:ClearAllChildren()
                player.Order.Value = false
            end
        end
    end 

    local playerProductKey = "p_" .. receiptInfo.PlayerId .. "_p_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

1 answer

Log in to vote
0
Answered by 10 years ago

is it a local script?

0
It's a regular script. Shawnyg 4330 — 10y
0
make it a local and see Blitz12234 10 — 10y
Ad

Answer this question