So I made a script that when you click on a button in a GUI it would let you buy the gamepass but if someone did buy the gamepass I want them to be teleported to the game "3650823073" the problem is I don't know how to make it verify if someone bought the gamepass or not because right now it would teleport people instantly even if they didn't buy the gamepass. Thanks for the help!
script.Parent.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 4725748) game:GetService("TeleportService"):Teleport(3650823073) end end)
Sorry for indentation!
script.Parent.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 4725748) game.MarketplaceService.PromptPurchaseFinished:Connect(function() if game.MarkerplaceService:PlayerOwnsAsset(game.Players.LocalPlayer,4725748) then game:GetService("TeleportService"):Teleport(game.Players.LocalPlayer,3650823073) end end) end)
Thanks to some help from a few people on the discord server I was able to get it working with this code below.
local MarketplaceService = game:GetService("MarketplaceService") local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, 4725748) end) game.MarketplaceService.PromptGamePassPurchaseFinished:Connect(function() if game.MarketplaceService:UserOwnsGamePassAsync(player.UserId,4725748) then game:GetService("TeleportService"):Teleport(3650823073) end end)