How to make a game teleporter

Hi there I am looking to make a game on a rocket. And I was looking to get support on how to make it that when the rocket surpusses a curtain height you will get teleported to another game.

tween the rocket to hit a part so the player could teleport

Make use of TeleportService and the :TeleportAsync() function belonging with it.
You could do something like

if rocket.Position.Y > height then
    teleportService:TeleportAsync(placeId, {player})
end

Detect when the rocket passes a height, then use Teleport Service to teleport players.
https://developer.roblox.com/en-us/api-reference/class/TeleportService

local TeleportService = game:GetService("TeleportService")

local placeId = 0

function Teleport(player)
	local Success, Error = pcall(function()
		TeleportService:Teleport(placeId, player)
	end) 
	return Success --was it successful?
end

local rocket = workspace.Rocket --rocket path
local teleportHeight = 100

local debounce = false

rocket:GetPropertyChangedSignal("Position"):Connect(function()
	if rocket.Position.Y >= teleportHeight and not debounce then 
        debounce = true
		Teleport(player)
	end
end)

Where do I put this script, like a part or in workspace?

Depends on how your game works. The script can be run client-side and server-side you just need to reference the rocket depending on script location(also also reference the player which is easier on the client cause of game.Players.LocalPlayer).

Can you walk me trough step by step of what i need to do, because my scripting knowledge is -100 IQ😅

  1. Do you want to teleport a single player or multiple players at the same time?
  2. where is your rocket located(on which explorer directory for example workspace.Part1)

I want the people on the rocket to be teleported and it is on workspace

You might want to check a part of the character instead otherwise they’ll be teleported even if they’re not currently in the rocket.

I just wrote down what OP wanted. To teleport players if a rocket reached a certain height.

Can someone help me step by step on how to do this? Like a detailed one if not, I will see what I can do :slight_smile:

That’s not quite true. In the documentation for TeleportService | Roblox Creator Documentation, in the errors table, one error it mentions will happen if it is called from the client. Its description is that it “Can only be called from the server”. This is usually true of all methods that have names ending in “Async”, as this implied it it making a web calls, and web calls can only be made from the server.

Thank you! I actually meant to type TeleportService:Teleport(placeId, player).

What can I do in simple script explanation?

1 Like

Try reusing the script but instead of TeleportAsync use Teleport (sorry for the typo).

I legit don’t know what you are saying, can you type an explanation that is user friendly?

use this inside a LocalScript in StarterPlayerScripts:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

local placeId = 0

function Teleport(player)
	local Success, Error = pcall(function()
		TeleportService:Teleport(placeId)
	end) 
	return Success --was it successful?
end

local rocket = workspace.Rocket --rocket path
local teleportHeight = 100

local debounce = false

rocket:GetPropertyChangedSignal("Position"):Connect(function()
	if rocket.Position.Y >= teleportHeight and not debounce then 
		debounce = true
		Teleport(player)
	end
end)

So when you pass a height barrier you will get teleported to where?