DevProucts not detected

Hey everyone,

My DevProducts script is acting weird. Sometimes it works great and gives me coins or kills all, but other times it doesn’t even print that I bought anything.

local MarketplaceService = game:GetService("MarketplaceService")

local products = {
	[1873719754] = 30,
	[1873720198] = 100,
	[1873720565] = 500,
	[1873721015] = 1000,
	[1927178173] = "KillAll"
}

local function processReceipt(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	local productId = receiptInfo.ProductId

	if products[productId] and type(products[productId]) == "number" then
		local leaderstats = player:WaitForChild("leaderstats")
		local coins = leaderstats:FindFirstChild("Coins")
		if coins then
			print("ProductId purchased: ", productId)
			wait(0.5)
			coins.Value += products[productId]
		end
	elseif products[productId] == "KillAll" then
		print("ProductId purchased: ", productId)
		wait(0.5)
		for _, plr in ipairs(game.Players:GetPlayers()) do
			if plr.Character then
				local hum = plr.Character:FindFirstChild("Humanoid")
				if hum then
					hum.Health = 0
				end
			end
		end
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end


MarketplaceService.ProcessReceipt = processReceipt

Never mind, my bad. I’ve read your entire script.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local productFunctions = {}

-- Example: product ID 123123 brings the user back to full health
productFunctions[123123] = function(receipt, player)
	local character = player.Character
	local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")

	if humanoid then
		humanoid.Health = humanoid.MaxHealth
		-- Indicates a successful purchase
		return true
	end
end

-- Example: product ID 456456 awards 100 gold coins to the user
productFunctions[456456] = function(receipt, player)
	local leaderstats = player:FindFirstChild("leaderstats")
	local gold = leaderstats and leaderstats:FindFirstChild("Gold")

	if gold then
		gold.Value += 100
		return true
	end
end

local function processReceipt(receiptInfo)
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if player then
		-- Gets the handler function associated with the developer product ID and attempts to run it
		local handler = productFunctions[productId]
		local success, result = pcall(handler, receiptInfo, player)
		if success then
			-- The user has received their items
			-- Returns "PurchaseGranted" to confirm the transaction
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			warn("Failed to process receipt:", receiptInfo, result)
		end
	end

	-- The user's items couldn't be awarded
	-- Returns "NotProcessedYet" and tries again next time the user joins the experience
	return Enum.ProductPurchaseDecision.NotProcessedYet
end

-- Sets the callback
-- This can only be done once by one server-side script
MarketplaceService.ProcessReceipt = processReceipt