Teleport question

Hello, I am making a teleporting system and was wondering how I would go about teleporting a single player, so far I have only figured out how to teleport the entire server which I don’t want to do! I have tried to use the “plr” from the remote event to no avail. That’s about it, if you have any questions please ask!

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


game.ReplicatedStorage.RemoteScripts.Teleport.OnServerEvent:Connect(function(plr,CODE)
	if CODE == workspace.PlaceCode.Value then
		else
	
	
	local players = Players:GetPlayers()  -- this is what I want to change to be one player
		
		print("okay teleporting!")
		TS:TeleportToPrivateServer(game.PlaceId,CODE,players) 
end	
end)






1 Like

Well, my guy, for this you’ll need the TeleportService, and a method from it that is called TeleportAsync() (the most common one). Which takes the placeID and the player instance (with an extra optional parameter, teleportOptions. An example of this could be done as:

local teleportresult = TeleportService:TeleportAsync(..., {player})

And this will basically get us the player into the place we want to teleport for also ... refers to the place ID, so don’t get confused with it. To use the TeleportService:TeleportToPrivateServer() we would do something like this:

TeleportService:TeleportToPrivateServer(placeID, reservedCode, {player})

And just like this we can actually do such as teleporting just one player! As easy as that my guy.

3 Likes

Is this for teleporting a player to another spot or another game?

Another game, given the placeId it-self, if it is a private server you’ll need to add the reservedCode for it to work!

Ok, Thank you so much sharkyboy.

1 Like