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

How do you make it so when you purchase a dev product your money goes up?

I created a script so when you purchase a dev product it gives you 1,000 cash but when I purchase it, nothing happens. How would I fix this? Also, I'm not getting any errors.

local MarketplaceService = game:GetService("MarketplaceService")
local devproductid = 437840868

MarketplaceService.ProcessReceipt = function(receiptInfo)
	for i, player in ipairs(game.Players:GetChildren()) do
		if player.userId == receiptInfo.PlayerId then
			if receiptInfo.ProductID == devproductid then
				player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1000
			end
		end
	end
end

3 comments

0

Either try capitalizing the I in id and p in product because that has happened to me in some cases where I forgot to capitalize

0

yes, case does matter

0

it already is

1 answer

✓ Accepted answer

Use this script instead:

local MPS = game:GetService("MarketplaceService")
 
MPS.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 437757000 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 50000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756922 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 10000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756846 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 5000
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756738 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 1500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756644 then -- replace with your ID here -----------------------
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 500
        return Enum.ProductPurchaseDecision.PurchaseGranted
    elseif receiptInfo.ProductId == 437756559 then -- replace with your ID here
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        player.leaderstats.bucks.Value = player.leaderstats.bucks.Value + 100
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

1 comment

0

THank you sO MUCH THIS HELPED ME IN MY GAME TYSM UR THE BEST OMG

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