Developer Products

I’m having some problems with Developer Products.

This is the code:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local Shop = require(game.Workspace.Important.Shop)
local DataStoreService = game:GetService("DataStoreService")

-- Data store for tracking purchases that were successfully processed
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")


local function GiveGuns(player, receiptInfo)
	for i, tool in pairs(Shop)do
		if tool.DevProductId == receiptInfo.ProductId then
			player.ToolsFolder[tool.Name].Value = true
			return true
		end
	end
end

-- The core 'ProcessReceipt' callback function
local function processReceipt(receiptInfo)

	-- Determine if the product was already granted by checking the data store  
	local playerProductKey = receiptInfo.PlayerId .. "_" .. receiptInfo.PurchaseId
	local purchased = false
	local success, errorMessage = pcall(function()
		purchased = purchaseHistoryStore:GetAsync(playerProductKey)
	end)
	-- If purchase was recorded, the product was already granted
	if success and purchased then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not success then
		error("Data store error:" .. errorMessage)
	end

	-- Find the player who made the purchase in the server
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not player then
		-- The player probably left the game
		-- If they come back, the callback will be called again
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	-- Look up handler function from 'productFunctions' table above
	local handler = GiveGuns(player, receiptInfo)

	-- Call the handler function and catch any errors
	local success, result = pcall(handler, receiptInfo, player)
	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	-- Record transaction in data store so it isn't granted again
	local success, errorMessage = pcall(function()
		purchaseHistoryStore:SetAsync(playerProductKey, true)
	end)
	if not success then
		error("Cannot save purchase data: " .. errorMessage)
	end

	-- IMPORTANT: Tell Roblox that the game successfully handled the purchase
	return Enum.ProductPurchaseDecision.PurchaseGranted
end

-- Set the callback; this can only be done once by one script on the server! 
MarketplaceService.ProcessReceipt = processReceipt

It was working some months ago and now it’s not working anymore.
I went to the Roblox wiki and I copied this code and changed it but still not working.
Btw, sometimes it works and sometimes stops working.
I really don’t know what to do.

Does it not work in-game or in studio?

It doesn’t work in both.
I made a print after this “local function processReceipt(receiptInfo)” and still not working
like this:
local function processReceipt(receiptInfo)
print(“Something”)

etc…

So it doesn’t print after you define the function?

Now it’s working again but idk what is wrong with this.