Processing a Receipt only working in Studio

I have this script, which just adds a value onto their data when you purchase a dev product, but for some reason, the script only works inside of Studio, and not inside an actual game.

I’ve tried a few different methods of fixing this that I read on other posts, but none of which seem to have worked, if you know please inform me. :slight_smile:

Script:

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

local Products = require(ReplicatedStorage:WaitForChild("Products"))
local SkipProduct = Products.ProductIds.Skip
local RebirthProduct = Products.ProductIds.Rebirth

local function processReceipt(recepitInfo)
	local player = game.Players:GetPlayerByUserId(recepitInfo.PlayerId)
	
	if player then
		local id = recepitInfo.ProductId
		
		if id == SkipProduct then
			player.Data.Skip.Value += 1
			return Enum.ProductPurchaseDecision.PurchaseGranted
		else
			if id == RebirthProduct then
				player.leaderstats.Stage.Value = 1
				player.leaderstats.Rebirth.Value += 1
				task.wait(1)
				player:LoadCharacter()
				return Enum.ProductPurchaseDecision.PurchaseGranted
			end
		end
	else
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
end

MarketplaceService.ProcessReceipt = processReceipt

If you have any ideas, please let me know.

2 Likes

Go to Game Settings > Security > Allow Third party Sales

That’s not the issue as it’s already enabled.

Are there any other ProcessReceipt events in any other script in the game? There can only be one ProcessReceipt callback in the game, if there’s multiple, only one of them will run, which might be the case here.

I’ve had a look, there’s only in the entire game.

Make sure you used ctrl + shift + f to search all scripts properly
Anyways, have you tried print debugging to see if the script runs properly and reaches the event?

Yeah I already used control + shift + f, there’s only one. I tried the print debugging, but as expected, it all works perfectly fine in studio, but when it comes to an actual game, it seems that the process receipt doesn’t even fire.

Did you print debug the script itself? As in, make sure the event is reached and connected to the callback function in the first place
i.e

print("Event reached")
MarketplaceService.ProcessReceipt = processReceipt

I’ve already done print debugging for the entire script, including the function I don’t know why it only works in studio.

Is there another script that uses ProcessReceipt? there can only be one who handles it.

Nope, there’s only one in the entire game.

This might be a very very long shot but, have you published the latest version?

It’s been published, yes, as well as tested on team test.