Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help On My Market Place Server Teleport?

So I am making a game where if you buy a pass you get teleported to a block. I'm not having trouble teleporting the person but, I am having trouble so when the person buys the pass from Market Place Service they teleport. This is my script:

local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent.Button
local productId = 25325022
local player = game.Players.LocalPlayer
 
buyButton.MouseButton1Click:connect(function()
	MarketplaceService:PromptProductPurchase(player, productId)
end)

while wait() do
	player.Character.Torso.CFrame = game.Workspace.Comeback.CFrame
end

1 answer

✓ Accepted answer

You'd need to use the PromptPurchaseFinished event. It fires once a user accepts or declines the purchase!

local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent.Button
local productId = 25325022
local player = game.Players.LocalPlayer

buyButton.MouseButton1Click:connect(function()
    MarketplaceService:PromptProductPurchase(player, productId)
end)

local MarketplaceService = game:GetService("MarketplaceService")
 
MarketplaceService.PromptPurchaseFinished:connect(function(player, productId, isPurchased)
	if isPurchased then
		player.Character.Torso.CFrame = game.Workspace.Comeback.CFrame
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.