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

How to make a dev product that multiplies the current money?

Asked by 4 years ago
Edited 4 years ago
local MPService = game:GetService("MarketplaceService")

MPService.ProcessReceipt = function(purchasInfo)
    local plr = game:GetService("Players"):GetPlayerByUserId(purchasInfo.PlayerId)
    if purchasInfo.ProductId == 989677509 then
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value * 2
    end
end

this is what I have, but when you buy the product a second time, the money multiplies by 4, 8, 16, and so on. How could you fix this?

Edit: It also seems to be printing a value twice, four times, and eight times, depending on how many times you've bought product

Edit 2: this multiplication issue seems to only persist with a dev product

1 answer

Log in to vote
1
Answered by 4 years ago
local MPService = game:GetService("MarketplaceService")
local origcash = nil

MPService.ProcessReceipt = function(purchaseInfo)
    local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
    if purchaseInfo.ProductId == 989677509 then
        origcash = plr.leaderstats.Money.Value
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + origcash
        wait(.4)
        origcash = nil
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

That Should Work. Also Don't Use *2 Because If The Game Lags Then The Player Will Gets Tons Of Cash.

0
Ah, I didn't consider lag. Thanks for this! DarkDanny04 407 — 4y
0
No Problem! Harry_TheKing1 325 — 4y
Ad

Answer this question