Developer product wont work

Hey everybody, for some reason when I buy the developer product, the prompt comes up and you buy it but nothing works after that and I’m not sure what is wrong with the script.

This whole script worked before I put it into the processreceipt function.

The script is down below.

marketplace.ProcessReceipt = function(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	print(player.Name)
	
	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if receiptInfo.ProductId == id then
		local boughtvalue = player:FindFirstChild("bought")
		local code, id = teleport:ReserveServer(game.PlaceId)
		print(code)

		boughtvalue.Value = true
		boughtvalue:SetAttribute("time", os.time() + 120)

		local joincode = generatecode()
		print(joincode)
		local privateservertable = {
			["PlayerOwner"] = nil,
			["ServerJoinCode"] = nil,
			["ServerJoinID"] = nil,
			["ResetServerCodeCooldown"] = nil
		}

		privateservertable.PlayerOwner = player.UserId
		privateservertable.ServerJoinCode = joincode
		privateservertable.ServerJoinID = id

		servercodes:SetAsync(joincode, code)

		servermain:SetAsync(player.UserId, privateservertable)
		
		print("Done")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

The “print(player.Name)” works but everything after that just doesn’t print or work.

My approach would be to try printing the receiptInfo data and confirm all is as expected. Then add a print after the if receiptInfo.ProductId == id then statement to confirm that if is being matched.

I added a print(receiptInfo) and a couple more print statements but the only ones that work is the print(receiptinfo) and the print("yay") under the if receiptInfo.ProductId == id.

This is the updated script.

marketplace.ProcessReceipt = function(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	print(player.Name)
	print(receiptInfo)
	
	if not player then
		print("Unmatched")
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	if receiptInfo.ProductId == id then
		print("yay")
		local boughtvalue = player:FindFirstChild("bought")
		local code, id = teleport:ReserveServer(game.PlaceId)
		print(code)
		print("Matched")

		boughtvalue.Value = true
		boughtvalue:SetAttribute("time", os.time() + 120)

		local joincode = generatecode()
		print(joincode)
		local privateservertable = {
			["PlayerOwner"] = nil,
			["ServerJoinCode"] = nil,
			["ServerJoinID"] = nil,
			["ResetServerCodeCooldown"] = nil
		}

		privateservertable.PlayerOwner = player.UserId
		privateservertable.ServerJoinCode = joincode
		privateservertable.ServerJoinID = id

		servercodes:SetAsync(joincode, code)

		servermain:SetAsync(player.UserId, privateservertable)
		
		print("Done")
		return Enum.ProductPurchaseDecision.PurchaseGranted
	end
end

It seems like the

local code, id = teleport:ReserveServer(game.PlaceId) is yielding the rest of the script. Is it because this is being run in studio?

I would think so. Most of TeleportService’s functions don’t work in Studio anyway.