Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help On My Market Place Server Teleport?

Asked by
Zelnus 30
9 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)

Ad

Answer this question