Error " Can only register ProcessReceipt callback on server"

You can write your topic however you want, but you need to answer these questions:
hi I’m kinda new to scripting i know a lot but i can figure out this problem

the problem is theres an error it says " Can only register ProcessReceipt callback on server"

i tried looking in devlogs in a server but it didnt work so im stuck

local MPS = game:GetService ("MarketplaceService")

MPS.ProcessReceipt = function(recieptInfo)
	if recieptInfo.ProductId == 171453062 then
		local player = game.Players:GetPlayerByUserId(recieptInfo.PlayerId)
		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value +1000
		return Enum.ProductPurchaseDecision.PurchaseGranted
 	end
end

please help if not have a great day!

You’re trying to assign MarketplaceService.ProcessReceipt from the client

It is extremely self-explanatory. You have to run this code in a server script. The client is expecting a callback from this, which it can only get from the server. It is like using a RemoteFunction, so you can only run MarketplaceSerive.ProcessReceipt on the server.


3 Likes

So how can i fix it? Btw thank you im starting to understand

Like the others said, you register ProcessReceipt on the server, not the client.

Put the code that registers ProcessReceipt on a Server Script, not a Local Script.

Literally just put the code in a server script. Insert a sever script into ServerScriptService, copy and paste the ProcessReceipt code into the script, then delete the code from the LocalScript. Delete the entire LocalScript if the ProcessReceipt function is the only code in that script.