How to teleport a player upon a product purchase

I recently have been trying to make a game where if a player purchases a devproduct, it teleports them to another place. I have already made everything including the GUI button and the devproduct. You can already purchase it, but it doesnt teleport you. I looked everywhere and even on third-party websites, nothing seemed to help.

Thanks in advance, Sprite :happy1:

1 Like

Hi, did you get any errors in the output?
Did you try adding a print function before the teleport function
and see if it prints? Maybe the teleport function doesn’t run at all
and something else is wrong.

I haven’t made my code yet, i don’t know how to use teleports.

Oh, alright.

You could get the PlayerId using ProcessReceipt and teleport them using TeleportService.

After you got the player, you can teleport the player from the server with this code:
TeleportService:Teleport(placeId, player)

1 Like

Do what @LotsOfBytes said, use that code. Remember to define TeleportedService first, though!

Here’s some code for checking if they have a gamepass.
Reply if you need anything.

-- ServerScript 
-- Configure this!
local passid = 1111 -- Your Gamepass ID here!
local gameid = 1111 -- Your game you want to teleport to ID here

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,passid) then
    	-- Teleport the Player!
game:GetService("TeleportService"):Teleport(gameid, plr)

Unless you are trying to teleport the player between places, just use this code. It will work on both Client and Server scripts:

local function teleportPlayer(player, position)