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

Theres this bug with my product recipt?

Asked by 3 years ago
game.MarketplaceService.ProcessReceipt = function(reciptInfo)
    local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
    if reciptInfo.ProductId == 1166140314 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50
    elseif reciptInfo.ProductId == 1166140360 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100
    elseif reciptInfo.ProductId == 1166140438 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250
    elseif reciptInfo.ProductId == 1166140622 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500
    elseif reciptInfo.ProductId == 1166140682 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000
    end
end

for some reason, when i buy something, for example the first one, it adds 50 tokens. But when i buy it again, it adds 100 tokens. and when i buy it for the third time, it add 150 tokens this time. It seems like it's adding 50 to every thing. how do i fix this?

2 answers

Log in to vote
0
Answered by 3 years ago
game.MarketplaceService.ProcessReceipt = function(reciptInfo)
    local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
    if reciptInfo.ProductId == 1166140314 then
        plr.leaderstats.Tokens.Value += 50
        return -- would it fix if you put a return after every purchase? or try PromptProductPurchaseFinished cos pro :)
    elseif reciptInfo.ProductId == 1166140360 then
        plr.leaderstats.Tokens.Value += 100
    elseif reciptInfo.ProductId == 1166140438 then
        plr.leaderstats.Tokens.Value += 250
    elseif reciptInfo.ProductId == 1166140622 then
        plr.leaderstats.Tokens.Value += 500
    elseif reciptInfo.ProductId == 1166140682 then
        plr.leaderstats.Tokens.Value += 1000
    end
end
0
Ok I will try! A_DistractionToYou 4 — 3y
0
Uh sorry, that didn't work. But do you have any idea how to use productpurchasefinished? A_DistractionToYou 4 — 3y
0
Oh wait, PromptProductPurchaseFinished wouldn't help because it could be like when the player closes the thing. A_DistractionToYou 4 — 3y
0
uh you could do like if canceled then return end BulletproofVast 1033 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Thanks! I used return but modified it a bit for it to work! Here's the finalized code.

game.MarketplaceService.ProcessReceipt = function(reciptInfo)
    local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId)
    if reciptInfo.ProductId == 1166140314 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif reciptInfo.ProductId == 1166140360 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif reciptInfo.ProductId == 1166140438 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif reciptInfo.ProductId == 1166140622 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif reciptInfo.ProductId == 1166140682 then
        plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

Answer this question