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

Dev Product (single purchase) doesn't work sometimes?

Asked by 4 years ago

I'm trying to get some dev products working and half the time they do not work, the purchase goes though but the actual code I'm running doesn't execute.

Here is my purchase handling (server side)

local Mps = game:GetService("MarketplaceService")
local DSS = game:GetService("DataStoreService")
local Plrs = game:GetService("Players")

Mps.ProcessReceipt = function(receiptInfo)
    local buyingplr = Plrs:GetPlayerByUserId(receiptInfo.PlayerId)
    if receiptInfo.ProductId == 1014292170 then
        if buyingplr and game.ServerStorage.PlayerMoney:FindFirstChild(buyingplr.Name) then
            local stats = game.ServerStorage.PlayerMoney[buyingplr.Name]
            stats.Value += 100000
        end
    end
    DSS:GetDataStore("ProductPurchases"):IncrementAsync(receiptInfo.PlayerId.."_"..receiptInfo.ProductId, 1)
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

and here is my local side handling

local Mps = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local prodID = 1014292170
local function promptPurchase()
    local player = players.LocalPlayer
    Mps:PromptProductPurchase(player, prodID)
end
script.Parent.MouseButton1Click:Connect(promptPurchase)

It tends to work for the first 20 seconds after the player joins, then it does nothing (unless you purchase within those 20 seconds or so then it works for the rest of the time you're in game)

Answer this question