Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Teleporting between Places in the Same Game?

I want to Teleport a Group of Players to a Certain Server in another Game i already know how to teleport but its ot guarenteed that they will all end up in the same one.

i know how to teleport already but it sends them to the wrong place.

function onTouched(hit)
   local player = game.Players:GetPlayerFromCharacter(hit.Parent)
   if player then
       game:GetService("TeleportService"):Teleport(0000000,player)  
  end
end


script.Parent.Touched:connect(onTouched)

I know i put 000000 there it does work

1 answer

✓ Accepted answer

You can use TeleportService:ReserveServer()

What this does, is it creates a sort of private server. Only people with the code can enter it. This code is created when you reserve a server.

Here's a basic script:

local TeleportService = game:GetService("TeleportService")

local function onHit(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	
	if player then
		local code = TeleportService:ReserveServer(game.PlaceId) -- Requires game to be published
		TeleportService:TeleportToPrivateServer(game.PlaceId, code, player)
	end
end)

I can understand if you do not want to teleport the players to a private server, however this is all the knowledge I could help you with.

For more information related to TeleportService visit this link: https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServer

4 comments

0

Where do i put the PlaceId for the other place?

0

You put it in the places where it says "game.PlaceId"

0

once the private server is create how could i teleport a diffeent player?

0

you can save the code of the reserved server and then use it again for a different player

This discussion is preserved as it was. New answers, comments, and votes are closed.