How to make a game teleporter?

What do you want to achieve?
I want to make a game teleporter, like when you walk on a part with this script, it teleports you to a certain game.

What is the issue?
I don’t arrive to do that.

What solutions have you tried so far?
I tried a few things with game teleportation but I can’t make this work.

Thanks in advance for your help! I hope you have a great day!

local TPS = game:GetService("TeleportService")

workspace.Part.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		TPS:Teleport(placeId,Player)
	end
end)

A very simple script. Let me know if there’s any bugs.

3 Likes

Thanks, but where do I put the place’s ID?

Uh, in the placeholder, where the text says “placeId.”

I replace placeID per the ID of my game?

I would recommend using TeleportAsync for its extra features.


local TPS = game:GetService("TeleportService")

workspace.Part.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		TPS:TeleportAsync(placeId,{Players}, TeleportOptions)
	end
end)

View teleport options docs or remove them, replace place id with the id of your place, and replace Players with your group of players or single player. Don’t remove the braces.

2 Likes

Yeah, so the teleport knows which game to teleport to.

1 Like

Thank you very much @ABrainDilemma and @2jammers!!

Sorry for the very late response, so I tried the script and it haven’t work…

Maybe I did something wrong somewhere?

This is it:

local TPS = game:GetService("TeleportService")

workspace.Part.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		TPS:TeleportAsync(11942106641,{Players}, TeleportOptions)
	end
end)

Also my script doesn’t teleport to a starting place but to a normal place so maybe that’s the problem?

Well first of all, you need to make {Players} {Player} because the players that are teleporting is your player, and the teleport options are optional. You can create them by using Instance.new(“TeleportOptions”)

So how would it looks in the script?


local TPS = game:GetService("TeleportService")

workspace.Part.Touched:Connect(function(Hit)
	local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		TPS:TeleportAsync(11942106641,{Player})
	end
end)

Thanks, I will try that!

Have a great day!

1 Like

I tried this script, and it does nothing when I touch the part… Do you know why?

1 Like

I tried this script I found from a Youtube video and it worked.

local GameId = "0" -- Put in your game ID here.
function Touched(Player)
	local FromChar = game.Players:GetPlayerFromCharacter(Player.Parent)
	if FromChar then
		local TeleService = game:GetService("TeleportService")
		TeleService:Teleport(GameId,FromChar)
	end
end
script.Parent.Touched:Connect(Touched)

Thanks you very much for you help, @ABrainDilemma and @2jammers!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.