Teleporting takes forever

  1. What do you want to achieve? Fix teleporting in my game.

  2. What is the issue? Whenever i step in the teleporter teleporting takes forever.

  3. What solutions have you tried so far? None, i just reviewed script but couldn’t find anything.

Script that shall teleport you:

local TS = game:GetService("TeleportService")
local TweenService = game:GetService("TweenService")
local placeId = "4890915942" -- Enter a second Id Place.
local leaveGuiEvent = game.ReplicatedStorage.LeaveGuiEvent
local TransitionEvent = game.ReplicatedStorage.TransitionEvent
local list = {}
local billboard = script.Parent.billboardPart.billboardGui
local timer
local teleporting = false
local spawnTeleport = script.Parent.spawn

local function updateGui()
	billboard.Frame.players.Text = "Players: " ..#list.. "/16" -- Change the number 16 according to the Max Player who want to be teleported.
end

local function removeFromList(character)
	for i=1,#list do
		if list[i] == character.Name then
			table.remove(list,i)
			updateGui()
		end
	end
end

local function teleportPlayers()
	if #list > 0 then
		billboard.Frame.Status.Text = "TELEPORTING"
		billboard.Frame.Status.TextColor3 = Color3.fromRGB(255, 0, 0)
		local playersToTeleport = {}
		local teleportTime = 0
		for i=1,#list do
			if game.Players:findFirstChild(list[i]) then
				table.insert(playersToTeleport,game.Players:findFirstChild(list[i]))
				TransitionEvent:FireClient(game.Players:findFirstChild(list[i]))
			else
				table.remove(list,i)	
			end
		end 
		local code = TS:ReserveServer(placeId)
		teleporting = true
		TS:TeleportToPrivateServer(placeId,code,playersToTeleport)
		repeat wait() until #list <= 0
		billboard.Frame.Status.Text = "READY"
		billboard.Frame.Status.TextColor3 = Color3.fromRGB(255, 0, 0)
		teleporting = false
	end
end

script.Parent.Gate.Touched:Connect(function(hit)
	if hit.Parent:findFirstChild("Humanoid") then
		if teleporting == false then
			local char = hit.Parent
			local player = game.Players:FindFirstChild(char.Name)
			local alreadyExists = false
			
			for i=1,#list do
				if list[i] == char.Name then
					alreadyExists = true
				end
			end
			
			if alreadyExists == false then
				if #list < 16 then -- Many Players have been teleported.
					table.insert(list,char.Name)
					char.PrimaryPart.CFrame = spawnTeleport.CFrame
					updateGui()
					leaveGuiEvent:FireClient(player)
				end
				
				player.CharacterRemoving:connect(function(character)
					removeFromList(character)
				end)
			end
			
		end
	end
end)

leaveGuiEvent.OnServerEvent:Connect(function(player)
	if player.Character then
		player.Character.HumanoidRootPart.Anchored = false
		wait()
		player.Character.Humanoid.Jump = true
		wait()
		player.Character:MoveTo(game.Workspace.leaveRoomPart.Position)
		removeFromList(player.Character)
	end
end)

while wait() do
	timer = 31
	for i=1,timer do
		timer = timer - 1
		billboard.Frame.time.Text = timer
		wait(1)
	end
	teleportPlayers()
end

Hope some body can help me.

3 Likes

This seems unnecessary.

4 Likes

The problem might just be how Roblox loads the player into the next world, which takes kinda long because of servers. However, you make this wait look and feel less weird by making a loading screen with gui.

1 Like

I had party gui before this and it said Attempted to teleport to a place that is restricted error code 773 maybe behind the gui there is the same error code 773?

2 Likes

What do you mean by behind the GUI is an error code? also how long does it take for the player to get teleport?

1 Like

Like i belive there is an error behind gui but people just cant see it. But i mean by teleporting ‘‘forever’’ that they dont even teleport.

1 Like

Is the place you made public to the other place that has the teleporters?

2 Likes

Yes, both of them are public. I dont really understand what did you ask.

1 Like

Does your script get any error inside of it?

1 Like

Nope i dont know why my message has to be atleast 30 words long lol.

1 Like

I haven’t done much teleporting script yet, however, I think you should just troubleshoot the whole script.
Try making a normal teleport by maybe following this video.How to Teleport Players to a Different Roblox Game - Roblox Studio Tutorial - YouTube
Then after that, you can edit it to make a list of all the players to teleport and teleport them one by one.

1 Like

It won’t help, the teleporters is like story teleporters with multiple people and gui.

? Aren’t you making a table of people to teleport to a private server, if so you could just get each player from that list and teleport them singly while using the script in the video.

Also, you can’t teleport inside of studio, you need to do it in the actual game to test it.

Im trying to make that all players teleport to another game in private server.

Im always trying to teleport in roblox client.

Im troubleshooting on my own studio, I’ll reply soon

1 Like

Okay well I tested a script from a youtube video, seems to work just fine.

local TPS = game:GetService("TeleportService")

game:GetService("ReplicatedStorage"):WaitForChild("Teleport").OnServerEvent:Connect(function(plr)
	local PlayerInQueue = {}
	table.insert(PlayerInQueue,plr)
	local placeId = 14290470865
	local PrivateServerCode = TPS:ReserveServer(placeId)
	
	TPS:TeleportToPrivateServer(placeId, PrivateServerCode, PlayerInQueue)
	table.clear(PlayerInQueue)
end)

Try using this but change it where you need it, if that doesn’t work. Then send me all of the items you are using to activate and teleport the player.

Could you please say where should i replace the script?

Would you like me to rewrite it for you? Just send me a pic of your explorer tab.