My script for Teleporting Dev Product doesn't work

So this script doesn’t seem to be working

local devproductid = script:WaitForChild("Gamepass ID").Value
local destination = game.Workspace:WaitForChild("Teleport To")
local marketplace = game:GetService("MarketplaceService")

game.ReplicatedStorage:WaitForChild("Teleport").OnServerEvent:Connect(function(player)
	if marketplace then
	if player and devproductid then
			if marketplace:GetDeveloperProductsAsync()(player.UserId, devproductid) then
			local char = game.Workspace:FindFirstChild(player.Name)
			if char then
			local root = char:FindFirstChild("HumanoidRootPart")
			if root and destination then
				root.Position = destination.Position
			end
			end
		else
			marketplace:PromptProductPurchase(player, devproductid)
		end
	end
	end
end)

Here’s a pic of the Explorer


Is there anything wrong? Thanks in advance.

Any errors? Can you show us the actual script cause there ain’t much we can do from just 1 screenshot from explorer?

1 Like

Shoot I just realized the script doesn’t show. Dumb me

Can you paste in the script between the 3 backticks (`). This makes it easier to edit, also the image for the script doesn’t show the script

1 Like

Sorry. My mistake. It’s there now.

GetDeveloperProductsAsync() only returns a list of dev products for that game. It doesn’t even take any parameters. You need to use the ProcessReciept event to detect whenever a player purchases a dev product/gamepass.

https://developer.roblox.com/en-us/api-reference/callback/MarketplaceService/ProcessReceipt

1 Like
 if marketplace:ProcessReceipt()(player.UserId, devproductid) then

this?

It doesn’t work.

MarketplaceService.ProcessReceipt is a property, you have to assign a function to it:

local function handleProcessReceipt(receiptInfo)
--	...
--	if successful:
--	return Enum.ProductPurchaseDecision.PurchaseGranted
--	if not successful:
--	return Enum.ProductPurchaseDecision.NotProcessedYet
end

game:GetService("MarketplaceService").ProcessReceipt = handleProcessReceipt

See the documentation here: MarketplaceService.ProcessReceipt

Also, you shouldn’t put this into a remote event: MarketplaceService.ProcessReceipt is fired automatically every time a player makes a developer product purchase.