Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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.

2 comments

0

Ah, I didn't consider lag. Thanks for this!

0

No Problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.