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

Dev Products give cash multiple times? [Solved]

Asked by 6 years ago
Edited 6 years ago

At this point I think its a roblox bug, but when I spam click my buy button, or the roblox buy button, or even when I buy dev products multiple times without spamming I start to get extra cash. I'm using datastores to record purchases, I've tried to save it in a table and saving it in a seperate key but when I check if the purchase id is the same as the purchase id saved in the datastore, it doesnt print out the message its supposed to. I'm using numbervalues to store my cash (if that matters).

Server Script:

marketPlaceService.ProcessReceipt = function(recieptInfo)
    local playerId = recieptInfo.PlayerId
    local productId = recieptInfo.ProductId
    local purchaseId = recieptInfo.PurchaseId 

    local player = game.Players:GetPlayerByUserId(playerId)

    local purchaseKey = playerId .. '_' .. purchaseId

    local cashPurchaseData = purchaseLogDataStore:GetAsync(purchaseKey) 

    if not player then print('Product already bought') return Enum.ProductPurchaseDecision.NotProcessedYet end

    if cashPurchaseData then return Enum.ProductPurchaseDecision.PurchaseGranted end

    --[[for i, v in pairs(cashPurchaseData) do
        print(v)
        print(purchaseId)
        if v == purchaseId then
            print('Purchase already completed')
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
    end--]]

    if productId == oneHundredKProductId then
        player.Money.Value = player.Money.Value + 100000
    elseif productId == fiveHundredKProductId then
        player.Money.Value = player.Money.Value + 500000
    elseif productId == oneMProductId then
        player.Money.Value = player.Money.Value + 1000000
    elseif productId == fiveMProductId then
        player.Money.Value = player.Money.Value + 5000000
    elseif productId == tenMProductId then
        player.Money.Value = player.Money.Value + 10000000
    end

    playerStatsDataStore:SetAsync(playerId .. '_cash', player.Money.Value)


    --table.insert(cashPurchaseData, purchaseId)

    purchaseLogDataStore:SetAsync(purchaseKey, true)

    print('Purchase Finished') -- This prints less times than the amount of cash I'm supposed to get with each purchase

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

Local Script:

marketPlaceService:PromptProductPurchase(player, selectedProduct)

wait(1) -

debounce = false -- I've added a debounce before this. 
0
I do not see anything wrong with this code as you do return the correct sate. Do you set ProcessReceipt once? User#5423 17 — 6y
0
yes i only use processreciept in one script (this one), i also return purchasegranted when needed. I honestly dont know why this is happening LifeInDevelopment 364 — 6y
0
you need to type in local Mps = game:GetService("MarketplaceService") Lolamtic 63 — 6y
View all comments (2 more)
0
Did my own solution, used update async instead of setasync and got the newvalue from updateasync and set that to the money value so it yields for that value. I also added a 5 second debounce. LifeInDevelopment 364 — 6y
0
If it works put [SOLVED] in the title Thundermaker300 554 — 6y

Answer this question