Money Dev Product no longer working

So a bit ago I made a few money dev products that worked great. However, the script no longer works. Here is the code:

local MarketplaceService = game:GetService("MarketplaceService")
local id1K = 1028794903
local id5K = 1028798902
local id10K = 1028800094
local id20K = 1028804566
local id50K = 1028805848
local id100K = 1028807694
local id500K = 1028808972
local id1M = 1028809389
local id1KReward = 1000
local id5KReward = 5000
local id10KReward = 10000
local id20KReward = 20000
local id50KReward = 50000
local id100KReward = 100000
local id500KReward = 500000
local id1MReward = 1000000
MarketplaceService.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == id1K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id1KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id5K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id5KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id10K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id10KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id20K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id20KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id50K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id50KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id100K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id100KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id500K then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id500KReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif receiptInfo.ProductId == id1M then
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		player.Stats.Money.Value = player.Stats.Money.Value + id1MReward
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

Any suggestions? Thanks!

Maybe you should stray away from the yanderedev technique and try something like this

local Products = {
    [00000] = function(receipt)
        --<Do magic
    end;
};

Marketplace.ProccessReceipt = function(receipt)
    local Matched = Products[receipt.ProductId];
        if(Matched) then Matched(receipt); end;
end)
1 Like

If you ever want to make so many repetitive things you should turn it into a table:

local MarketService = game:GetService("Marketplaces device")

local TableWithIds= {
    [1] = function()
        -- do whatever
    end;
    [2] = function ()
        -- do something else
    end;
}

MarketService.ProcessReceipt = function(info)
    if TableWithIds[info.ProductId] then
        TableWithIds[info.ProductId]()
    end
end

Welp, I got ninjaed.

Huh, still seems to not work. This is my new code:

local MarketplaceService = game:GetService("MarketplaceService")
local products = {}
products[1028794903] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 1000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028798902] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 5000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028800094] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 10000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028804566] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 20000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028805848] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 50000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028807694] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 100000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028808972] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 500000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
products[1028809389] = function(receiptInfo)
	local player = game.Players[game.Players:GetNameFromUserIdAsync(receiptInfo.PlayerId)]
	player.Stats.Money.Value = player.Stats.Money.Value + 1000000
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
	if products[receiptInfo.ProductId] then
		products[receiptInfo.ProductId](receiptInfo)
	end
end

I think I understand the problem. This page shows that “As with all callbacks, this function should be set once and only once by a single Script . If you’re selling multiple products in your game, this callback must handle receipts for all of them.” though I have another script with the ProcessReceipt callback. Turning it into 1 script fixed everything.