Dev Product only rewarded when rejoin

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the dev product to be rewarded when the player buys the product on the spot.

  2. What is the issue? Include screenshots / videos if possible!
    I have tested this code on a clean fresh plate and it works. However, when I place the code on another game (changing the dev product ID), it only works when the player rejoins the game after purchase.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    As mentioned above, it only worked in a clean place, but not on this other game.

local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local nukeID = 1301147140

-- The core 'ProcessReceipt' callback function
local function processReceipt(receiptInfo)
	print("process receipt")
	local userId = receiptInfo.PlayerId
	local productId = receiptInfo.ProductId

	local player = Players:GetPlayerByUserId(userId)
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet

		if receiptInfo.ProductId == nukeID then -- nuke code
			-- active code goes here

	return Enum.ProductPurchaseDecision.PurchaseGranted

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

Basically, what I am looking for is why the code only runs when you purchase and rejoin.

Do you have any other scripts that run in your other place, making it yield until you rejoin?

1 Like

Yes, I forgot I posted this question, but it was a donation script using a similar processReceipt function, and I’ve read on that one script should only use the processReceipt script.

1 Like