How do I teleport a player

How can I teleport a player when they use a proximity prompt? I tried following the tutorial but all it did is get me more confused. I don’t know any scripting so if you just tell me code I won’t know where to put it so please tell me what to put it under in explorer. Thanks everyone!

P.S. I will be teleporting them both within the game and to other games/places depending on the prompt so you can give me either code and I’ll be able to do it.

You can use teleport service if your saying that the proximity prompt is meant to teleport the player to another game

But I know this much about scritping: :pinching_hand:

I don’t know how to use teleport service, if I did then I wouldn’t need help.

Within the game:

local proximityPrompt = script.Parent
local partToTeleportTo = workspace.PartToTeleport

proximityPrompt.Triggered:Connect(function(player) -- When the proximity prompt is triggered, it will return a player value. We can use this in our code!

     local character = player.Character -- This returns the character model of the player
     character.HumanoidRootPart.Position = partToTeleportTo.Position -- This sets the humanoidrootpart of the player to the part you want to teleport to's position. Since the character is connected to the humanoidRootPart, the whole character will come along!

end)

Read the comments to find out what each line of code does!
Hope this helps!

1 Like
---- Note: Make sure you enabled "Allow Third Party Teleports" In Game Settings > Security.

local TeleportService = game:GetService("TeleportService") --- Get Teleport Service.

local Part = script.Parent ---- Part.

local PlaceId = 1234567890 ---- Replace this with place id.

local ProximityPrompt = Part.ProximityPrompt ---- Get ProximityPrompt In Part.

ProximityPrompt.Triggered:Connect(function(Player) ---- Runs Code When ProximityPrompt Triggered.

TeleportService:Teleport(PlaceId, Player)

end)
1 Like

If I was supposed to put this under the prompt then it doesn’t work. Idk why.

Any errors? You must always look at errors while scripting!

How do I look at errors? Is it fn+f9 like in games?

Go to the View tab and click ‘Output’
If there are any red sentences, that is an error!

1 Like

Here’s my output:

Alright, that is nothing to do with the proximity prompt then. Where have you put the proximity prompt at? Remember, you have to put it inside a part. And also remember to create a separate part called ‘PartToTeleport’ in workspace!

I did put it inside a part and I have a separate part called that.

Tried it, this doesn’t work either.

I unfortunately have nothing to help me figure out what’s going wrong.

Ok, I didn’t think I could be so bad a scripter that working code doesn’t work for me :joy:

It’s not that you are a bad scripter. You are new to developing, and you need to keep persisting! Maybe work on this with a fresh mind tomorrow and you might just find a solution!

Ya, I was joking. I’ll try tomorrow