How do i fix this teleporting script

You can also add a code argument into the Teleport function when it is called.

1 Like

thats not the issue, when i try to teleport with a working code it refuses to teleport me to the server and gives me error 769

769 means something unexpected happened. Make sure you aren’t teleporting in studio, you have HTTP and third party teleports on. If you have and you still have this error, let me know.

1 Like

everything are on and ran in a normal player

local TPService = game:GetService("TeleportService") -- Get the TP service

local Target = 0 -- UserId of the player you want to TP, leave as 0 if you want to TP everyone

function Teleport() -- This function can be called at any time
local TPCode = TPService:ReserveServer(game.PlaceId) -- Replace this if you want to
local PlaceID = 0 -- Update to your PlaceId, not GameId
local PlrsToTP = {}

for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
	if Player.UserId == Target or Target == 0 then
		table.insert(PlrsToTP,#PlrsToTP+1,Player) -- Insert player to TP into TP table
	end
end

TPService:TeleportToPrivateServer(PlaceID,TPCode,PlrsToTP) -- Teleport
end

The thing was you need to give the TPService a PlaceId, not a GameId. Try out this code or change it in yours.

1 Like

A similiar thing happened to this Teleport failed due to an unexpected error [Error Code: 769] When I tried to teleport to a reserve server guy, he also got the 769 error. He said: “I was just putting the wrong variable”. Let me know if the code I sent helped you :slight_smile:

1 Like

thats what i used in my scripts i used game.PlaceId

I don’t know then. Try reading this article TeleportService | Roblox Creator Documentation, maybe it helps.

2 Likes

alright thanks for your help imma try checking the documentation like u said

when i looked at the client it gave me this and im not sure how is my code wrong even tho i described it before sending

It says that the code isn’t valid. Either you are getting the code but changing it or generating a random code. You should just use TPService:ReserveServer(game.PlaceId) to get the code and use it.

1 Like

Also, you can call TPService:ReserveServer() only from server, not client.

1 Like

the server starts basically with a player joins a reserved server and another one tries to join him using the code of the reserved server

i think the only solution is to use teleport data while sending the player to the reserved server so they obtain the code once they enter without usnig game.privateserverid

Does the code stay the same or do you modify it?

the code stays the same the moment i get it from the sending script and the moment i recieve it ,its still the same

If the code is still same, then I don’t see a problem with this.

imma try to get the code from the moment the server is made

ok i found the main issue, the code of the game.PrivateServerId is different from the code given before teleportation for some reasons so all i need to do is to save the code somehow before joining maybe using datastore or some stuff like that imma try to find a way

Yes I suggest using Datastores to save the code, so it can be accessed from anywhere.

1 Like