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

Proper Use of Developer Products?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 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. Yes, I do not this is a repeat question, as my previous question only received on answer that wasn't very helpful, and it's been days.

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
0
This more than likely won't change anything, but replace 'game.Players:GetChildren()' with 'game.Players:GetPlayers()'? Redbullusa 1580 — 9y
0
Yeah, didn't change anything. Thanks for trying. Shawnyg 4330 — 9y

Answer this question