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)
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.
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
Also, you shouldn’t put this into a remote event: MarketplaceService.ProcessReceipt is fired automatically every time a player makes a developer product purchase.