ProcessReceipt - Devproduct

The devproduct handler only works in the studio and even prints it all out perfectly, but when I try it in a game server it wouldn’t even trigger the first function…

--//Receipts Handler\\--
MarketplaceService.ProcessReceipt = function(recieptInfo)
	print(1)
	local Player = Players:GetPlayerByUserId(recieptInfo.PlayerId)
	if not Player then
		print(2)
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	if recieptInfo.ProductId == devProduct then
		print(3)
		for _, plr in Players:GetPlayers() do
			print(4)
			if (plr.UserId ~= Player.UserId) then
				print(5)
				local Character = plr.Character
				local Humanoid = Character:FindFirstChild("Humanoid")
				if Humanoid then
					print(6)
					Humanoid.Health = 0
				end
			end
		end
		KillAllValidation:FireAllClients(Player)
	end
	return Enum.ProductPurchaseDecision.PurchaseGranted
end
2 Likes

It only works on the Roblox studio and not on the Roblox launcher, please can som1 review it?^^

are there any other scripts in your game that use ProcessRecipt?
you can only call ProcessRecipt once within all scripts.

if you have inserted any models from the toolbox make sure that they dont use ProcessRecipt too.

it could also simply be a studio bug.

1 Like

So I’m saying the script works in studio when I run it, it checks out it does anything as written but when, I publish it, Save it whatnot… and yet when I try it in game through the Roblox launcher not even one print works…


1 Like

yes - sorry, i understand.

if you set MarketplaceService.ProcessReceipt in any other scripts in your game then the script that you are currently editing may not register ProcessReceipt, so check the scripts in your game (particularly scripts from any free models you have inserted, if any) and add any instances of ProcessReceipt to your current script.

for example,
in the first screenshot you sent, it looks like you have a clothing picker.
67fb4ee01242b36817aa3f1fc85532c1711d3eda
if that clothing picker allows you to purchase the clothes, and uses
MarketplaceService.ProcessReceipt, then you might not be able to use MarketplaceService.ProcessReceipt in your script.
.
if you would like me to explain anything in further detail, let me know!

1 Like

I saw in your output there was an error. Is that error related?
Maybe add some print statements to make sure the Humanoid is being found?

Also, I’d recommend using the structure in the documentation for receipt processing, it has more security.

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

local productFunctions = {}

productFunctions[123123] = function(info, player) --the numbers is your product ID
	player.leaderstats.Money.Value += 300 --as an example
	return true
end

local function processReceipt(info)
	local player = players:GetPlayerByUserId(info.PlayerId)
	local handler = productFunctions[info.ProductId]
	
	local success, result = pcall(handler, info, player)
	
	if success then
		return Enum.ProductPurchaseDecision.PurchaseGranted
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

mps.ProcessReceipt = processReceipt

Are you sure you are testing in the correct conditions? It seems as if there is noone in the server based on how far the code reached…

It’s not my game but a commission I do, it turns out he had a donation board that process receipts in a module of course I’ve first checked if there’s anything that uses processreceipt function but now when I looked deeper I tried to disable the donations board and it works, thanks.

1 Like

Thanks for trying to help but no offence, everything you wrote is just wrong ,

  1. You don’t have to use the documentation code structure etc.

  2. There’s no error related to humanoid nor anything within my scripts or code simply sound assets lack of permissions error,

  3. If you really been trying to help you would’ve seen there are prints all around the original code.

So thanks but no thanks.

Obviously I tested it along with testers dozens of times what type of question is that when the if statement of the player.id ~= receiptinfo.playerid can be simply removed or modified and I can test it on my self, not to mention I didn’t do it and I had testers…

My bad I was looking at the wrong image :skull:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.