Developer Product not working right

I have a script for some dev products, the first one being a 49 robux purchase for a one time gain of a stat, second being for a 10 times gain of a stat and the third being a 100x gain of a stat. For some reason, only the 100x code works, however, for example if I delete the code for the 100x and 10x then all of a sudden the first block starts working again. These used to be in separate scripts, but that wasn’t working so I put them all in one but it didn’t do anything

local MPS = game:GetService("MarketplaceService")
local x = require(game.ReplicatedStorage.EternityNum)
local RarityList = require(game.ServerStorage.Luck)

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 1738019784 then 
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		local s =player:FindFirstChild("Stats")
		local ro = player.Stats:FindFirstChild("RunesOpened")
		local mvp = player.Stats:FindFirstChild("MVP")
		local rg = player.Stats:FindFirstChild("RuneMaster")

		local RarityWeights = {
			{name = "Gilded", weight = 70},
			{name = "Temporal",  weight = 25},
			{name = "Binary", weight = 4},
			{name = "Ethereal", weight = 2},
			{name = "Celestial", weight = 0.1},
		}

		local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
		local stt = player.Stats:FindFirstChild(SelectedRarity.name)
		local svb = x.convert(stt.Value)
		local val =x.convert(1)

		local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
		local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

		svb = x.add(svb, val)
		stt.Value = x.bnumtostr(svb)
		ro.Value = ro.Value + 1

	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 1738056917 then 
		for i = 1, 10 do
			local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
			local s =player:FindFirstChild("Stats")
			local ro = player.Stats:FindFirstChild("RunesOpened")
			local mvp = player.Stats:FindFirstChild("MVP")
			local rg = player.Stats:FindFirstChild("RuneMaster")

			local RarityWeights = {
				{name = "Gilded", weight = 70},
				{name = "Temporal",  weight = 25},
				{name = "Binary", weight = 4},
				{name = "Ethereal", weight = 2},
				{name = "Celestial", weight = 0.1},
			}

			local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
			local stt = player.Stats:FindFirstChild(SelectedRarity.name)
			local svb = x.convert(stt.Value)
			local val =x.convert(1)

			local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
			local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

			svb = x.add(svb, val)
			stt.Value = x.bnumtostr(svb)
			ro.Value = ro.Value + 1

		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 1738058940 then 
		for i = 1, 100 do
			local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
			local s =player:FindFirstChild("Stats")
			local ro = player.Stats:FindFirstChild("RunesOpened")
			local mvp = player.Stats:FindFirstChild("MVP")
			local rg = player.Stats:FindFirstChild("RuneMaster")

			local RarityWeights = {
				{name = "Gilded", weight = 70},
				{name = "Temporal",  weight = 25},
				{name = "Binary", weight = 4},
				{name = "Ethereal", weight = 2},
				{name = "Celestial", weight = 0.1},
			}

			local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
			local stt = player.Stats:FindFirstChild(SelectedRarity.name)
			local svb = x.convert(stt.Value)
			local val =x.convert(1)

			local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
			local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

			svb = x.add(svb, val)
			stt.Value = x.bnumtostr(svb)
			ro.Value = ro.Value + 1

		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
1 Like

The problem here is that each “block” overwrites the previous function set to ProcessReceipt, this value cannot store multiple functions, so what ends up happening is each function you assign to it overwrites the previous one, as a result, only the 100x option works since it’s assigned last, try this instead:

local MPS = game:GetService("MarketplaceService")
local x = require(game.ReplicatedStorage.EternityNum)
local RarityList = require(game.ServerStorage.Luck)

MPS.ProcessReceipt = function(receiptInfo)
	if receiptInfo.ProductId == 1738019784 then 
		local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
		local s =player:FindFirstChild("Stats")
		local ro = player.Stats:FindFirstChild("RunesOpened")
		local mvp = player.Stats:FindFirstChild("MVP")
		local rg = player.Stats:FindFirstChild("RuneMaster")

		local RarityWeights = {
			{name = "Gilded", weight = 70},
			{name = "Temporal",  weight = 25},
			{name = "Binary", weight = 4},
			{name = "Ethereal", weight = 2},
			{name = "Celestial", weight = 0.1},
		}

		local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
		local stt = player.Stats:FindFirstChild(SelectedRarity.name)
		local svb = x.convert(stt.Value)
		local val =x.convert(1)

		local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
		local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

		svb = x.add(svb, val)
		stt.Value = x.bnumtostr(svb)
		ro.Value = ro.Value + 1

	elseif receiptInfo.ProductId == 1738056917 then 
		for i = 1, 10 do
			local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
			local s =player:FindFirstChild("Stats")
			local ro = player.Stats:FindFirstChild("RunesOpened")
			local mvp = player.Stats:FindFirstChild("MVP")
			local rg = player.Stats:FindFirstChild("RuneMaster")

			local RarityWeights = {
				{name = "Gilded", weight = 70},
				{name = "Temporal",  weight = 25},
				{name = "Binary", weight = 4},
				{name = "Ethereal", weight = 2},
				{name = "Celestial", weight = 0.1},
			}

			local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
			local stt = player.Stats:FindFirstChild(SelectedRarity.name)
			local svb = x.convert(stt.Value)
			local val =x.convert(1)

			local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
			local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

			svb = x.add(svb, val)
			stt.Value = x.bnumtostr(svb)
			ro.Value = ro.Value + 1

		end
	elseif receiptInfo.ProductId == 1738058940 then 
		for i = 1, 100 do
			local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
			local s =player:FindFirstChild("Stats")
			local ro = player.Stats:FindFirstChild("RunesOpened")
			local mvp = player.Stats:FindFirstChild("MVP")
			local rg = player.Stats:FindFirstChild("RuneMaster")

			local RarityWeights = {
				{name = "Gilded", weight = 70},
				{name = "Temporal",  weight = 25},
				{name = "Binary", weight = 4},
				{name = "Ethereal", weight = 2},
				{name = "Celestial", weight = 0.1},
			}

			local SelectedRarity = RarityList.SelectRarity(RarityWeights) -- Gives rarity
			local stt = player.Stats:FindFirstChild(SelectedRarity.name)
			local svb = x.convert(stt.Value)
			local val =x.convert(1)

			local val = x.mul(val, (x.add(x.mul(x.convert(mvp.Value),{1,0}),{1,0})))
			local val = x.mul(val, (x.add(x.mul(x.convert(rg.Value),{2,0}),{1,0})))

			svb = x.add(svb, val)
			stt.Value = x.bnumtostr(svb)
			ro.Value = ro.Value + 1

		end
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
1 Like