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

Could someone help me debug this script(regarding dev products)?

Someone in an earlier question helped me make a script that gives the player a certain amount of cash when purchasing a dev product. It worked with one but after stacking multiple products it didn't work. Here it is:

game:GetService("MarketplaceService").ProcessReceipt = function(purchaseInfo)
    local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId) --Defines the player who bought the product
	if purchaseInfo.ProductId == 951160290 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 100 --Cash to be given
    end
    if purchaseInfo.ProductId == 951160339 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 500 --Cash to be given
    end
	if purchaseInfo.ProductId == 951160900 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 1500 --Cash to be given
	end
	if purchaseInfo.ProductId == 951160941 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 3000 --Cash to be given
	end
	if purchaseInfo.ProductId == 951160984 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 5000 --Cash to be given
	end
	if purchaseInfo.ProductId == 951161055 then --Replace with your product ID
        plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 10000 --Cash to be given
    end
	
    return Enum.ProductPurchaseDecision.PurchaseGranted --Makes sure the player has bought the DevProduct
end

NOTE: I also tried separating them into separate scripts but it still didn't work.

1 answer

Try this: local MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 944587847 then -- replace with your ID here
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.leaderstats.Gems.Value = player.leaderstats.Gems.Value + 100000 -- CHANGE THIS TO YOUR CURRENCY
		return Enum.ProductPurchaseDecision.PurchaseGranted

TO COPY: https://pastebin.com/raw/C2yZCn2H

2 comments

0

That's what I originally did. I tried separate scripts and together, still didn't work

0

bruh just use a print function if you dont know whats going on

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