Problems with scripts only in team create

I have a script to process a receipt, and it works fine regularly, but it won’t work in team create. Here’s the script:

local function processReceipt(receiptInfo)
	print("purchase", receiptInfo)
	print("callback fired")	
	local productKey = receiptInfo.PlayerId.."_"..receiptInfo.PurchaseId
	local purchased = false
	local success, result, errorMessage
	print("Variables found")
	
	success, errorMessage = pcall(function()
		purchased = purchaseHistoryStore:GetAsync(productKey)
	end)
	if success and purchased then
		print("Purchase Granted")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	elseif not success then
		error("Data store error:"..errorMessage)
	end
	
	local success, isPurchaseRecorded = pcall(function()
		return purchaseHistoryStore:UpdateAsync(productKey, function(alreadyPurchased)
			if alreadyPurchased then
				print("already purchased")
				return true
			end
			
			local plr = Players:GetPlayerByUserId(receiptInfo.PlayerId)
			if not plr then
				print("player not found")
				return nil
			end
			
			local handler = productFunctions[receiptInfo.ProductId]
			print("product function found")
			
			local success, result = pcall(handler, receiptInfo, plr)
			if not success then
				error("Failed to process a product purchase for ProductId: "..tostring(receiptInfo.ProductId).." Player: "..tostring(plr).." Error: "..tostring(result))
				return nil
			end	
			print("pcall for product function done")
			return true
		end)
	end)
	
	if not success then
		error("Failed to process receipt due to data store error.")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	elseif isPurchaseRecorded == nil then
		print("not processed yet")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	else
		print("purchase granted")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

MarketplaceService.ProcessReceipt = processReceipt

Why is this happening?

1 Like

Could this maybe be a bug? I have no idea why it won’t work in team create, but it will work without it. Does anyone have any ideas?

For a script to work on team create you have to commit it.

No?

You are able to turn this off within the settings of your game.

They are already committed.
(char limit)