How to perfectly make developer products?

I have been learning to make roblox games, but recently I got an issue where the code is correct but the thing doesn’t work.
I am doing as per this roblox website.

But even when i do the similar kind of thing it doesn’t work. Can anyone correct me where I’m going wrong?


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

local donateEvent = ReplicatedStorage:WaitForChild("donateEvent")

local ProductFunctions = {}

ProductFunctions[1249752191] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752535] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752534] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752537] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752533] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752530] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752532] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752536] = function(Player)
	donateEvent:FireClient(Player)
end
ProductFunctions[1249752531] = function(Player)
	donateEvent:FireClient(Player)
end

MarketPlaceService.ProcessReceipt = function(info)
	local Player = Players:GetPlayerByUserId(info.PlayerId)
	local Product = info.PurchaseId

	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	local success, err = pcall(ProductFunctions[Product],Player)
	if not success then
		warn('error')
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end

My problem here is that even though the process receipt is there and the ID exactly matches with the given values to be checked. The event inside the function doesn’t fire at all! Not even 1 event is fired in all of them…

This is a server script

If i did anything wrong pls help me on how to correct it. Thanks

Could you kindly print the final output from the client’s .OnClientEvent? Edit: Or is the server event firing and the client just isn’t receiving the event? If the client isn’t firing, could you kindly print the portion of script receiving the server event?

I don’t understand cuz I’m new to lua
But when i tried printing some things i saw that success variable is false.

local success, err = pcall(ProductFunctions[Product],Player)

success depends on the function returning true if I’m not mistaken,

ProductFunctions[1249752532] = function(Player)
   local PlayerCheck = Player
   donateEvent:FireClient(Player)
   donateEvent.OnServerEvent:Connect(function(Player, money)
        if money == --put the money they're supposed to have here
              return true
        else
              return false
        end
    end
end
--- this OnServerEvent waits for a player to return their # of money
--- if it matches what the function sent the player then continue

Thanks for your suggestion, but still it doesn’t work. The success is still false and the err is nil

Well the problem was that i wrote

local Product = info.PurchaseId

It should actually be

local Product = info.ProductId