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

Teleport Failed to an unexpected error?

I'm making a game and im sending people to a separate place within my game. It's a reserved Server so only the people I send will be able to join. Whenever I test it out in Game(Not studio mode) it always pulls up with "Teleport Failed to an unexpected error.(Error Code:769)" Please Help.

local tpService = game:GetService("TeleportService")
local place = (Im not Showing This)

script.Parent.Touched:Connect(function(hit)
	local code = tpService:ReserveServer(game.PlaceId)
	local player = game.Players:GetChildren()
	if player then
		tpService:TeleportToPrivateServer(place,code,player,"StartSpawn",nil,nil)
	end
end)

2 comments

0

What just happened to the views XD

0

Are you trying to create a private server in a new game or the current game?

1 answer

✓ Accepted answer

Seems to work for me, my guess is your 'place' id variable wasn't the same as game.PlaceId

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

local PlaceId = game.PlaceId
local ReservedServerCode = TeleportService:ReserveServer(PlaceId)

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent then 
		local Player = PlayersService:GetPlayerFromCharacter(hit.Parent)
		if Player and Player.Character then 
			local Humanoid = Player.Character:FindFirstChild("Humanoid")
			if Humanoid and Humanoid.Health > 0 then
				-- Use the GetPlayers() method on Players
				local Players = PlayersService:GetPlayers()
				-- Should be > 0 since someone stepped on it
				if #Players > 0 then 
					TeleportService:TeleportToPrivateServer(PlaceId, ReservedServerCode, Players, "StartSpawn")
				end
			end
		end
	end
end)

1 comment

0

Thanks I was putting making the server code every time the part was hit. Oops.

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