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
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)