TeleportAsync not working

  1. I want to make a global matchmaking system

  2. My issue is this: image

  3. I went in so many social medias to know how to fix my problem
    -YouTube
    -The Developer Forum
    -Reddit
    -The Roblox Engine API

I’ve never found a solution.

My ServerScript with the error

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MessagingService = game:GetService("MessagingService")
local TeleportService = game:GetService("TeleportService")
local Debris = game:GetService("Debris")
local Players = game:GetService("ReplicatedStorage"):WaitForChild("Players")
local ReadyEvent = ReplicatedStorage:WaitForChild("Ready")
local UnreadyEvent = ReplicatedStorage:WaitForChild("Unready")
local Room = {}

game.Players.PlayerAdded:Connect(function(Player)

ReadyEvent.OnServerEvent:Connect(function(Plr)
	MessagingService:PublishAsync("Ready", "Ready")
end)

UnreadyEvent.OnServerEvent:Connect(function(Plr)
	MessagingService:PublishAsync("Unready", "Unready")
end)

MessagingService:SubscribeAsync("Ready", function(value)
	if Players:FindFirstChild(Player.Name) == nil then
		local PlayerValue = Instance.new("ObjectValue")
		PlayerValue.Value = Player
		PlayerValue.Name = Player.Name
		PlayerValue.Parent = Players
		task.wait()
		MessagingService:PublishAsync("NumberOfPlayers", #Players:GetChildren())
	end
end)

MessagingService:SubscribeAsync("Unready", function(value)
local ifPlayerFound = Players:FindFirstChild(Player.Name)
	if ifPlayerFound then
		Debris:AddItem(ifPlayerFound, 0)
		task.wait(0.1)
		MessagingService:PublishAsync("NumberOfPlayers", #Players:GetChildren())
	end
end)

MessagingService:SubscribeAsync("NumberOfPlayers", function(number)
	if number.Data == 1 then
	Player.PlayerGui.ScreenGui.TextLabel.Text = "1 player is ready"
	else
	Player.PlayerGui.ScreenGui.TextLabel.Text = number.Data.." players are ready"
	end
end)

print(#Players:GetChildren())

while task.wait(10) do
	
for i, v in pairs(Players:GetChildren()) do
	table.insert(Room, v.Value)	
end
	
local success, err = pcall(function()
TeleportService:TeleportAsync(4972532928, Room, Enum.TeleportType.ToReservedServer)
end)
table.clear(Room)
if not success then
	warn(err)
end

end
	
end)
1 Like

Hello maybe the problem is with object does object have codes if yes then i guess you made a mistake on code (im not good at code things but i hope this can help out) and i do have teleporting system for my game maybe you can checkout

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local TeleportService = game:GetService("TeleportService")

local SafeTeleport = require(ServerScriptService.SafeTeleport)

local movingEvent = ReplicatedStorage:WaitForChild("MovingElevator")
local elevatorEvent = ReplicatedStorage:WaitForChild("Elevator")
local elevator = script.Parent
local prismatic = elevator.Shaft.PrismaticConstraint
local gui = elevator.Screen.Attachment.TimeGui
local mapgui = elevator.Screen.MapGui.ProgressBar
local config = elevator.Config
local playersWaiting = {}
local countdownRunning = false
local moving = false

local function Setup()
	playersWaiting = {}
	moving = false
	mapgui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value
	gui.Status.Text = "Players Needed"	
end

local function TeleportPlayers()
	local placeId = 14361189698
	local server = TeleportService:ReserveServer(placeId)
	local options = Instance.new("TeleportOptions")
	options.ReservedServerAccessCode = server
	SafeTeleport(placeId, playersWaiting, options)
	print("Finished Teleport")
end

local function MoveElevator()
	moving = true
	for i, player in pairs(playersWaiting) do
		movingEvent:FireClient(player)
	end
	gui.Status.Text = "Teleporting Players..."
	prismatic.TargetPosition = -20
	TeleportPlayers()
	task.wait(10)
	prismatic.TargetPosition = 0
	task.wait(8)
	Setup()
end

local function RunCountdown()
	countdownRunning = true
	for i=15, 1, -1 do
		gui.Status.Text = "Starting: " .. i
		task.wait(1)
		if #playersWaiting < 1 then 
			countdownRunning = false
			Setup()
			return
		end
	end
	MoveElevator()
	countdownRunning = false
end

elevator.Entrance.Touched:Connect(function(part)
	local player =  Players:GetPlayerFromCharacter(part.Parent)
	local isWaiting = table.find(playersWaiting, player)
	
	if player and not isWaiting and #playersWaiting < config.MaxPlayers.Value and not moving then 
		table.insert(playersWaiting, player)
		mapgui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value
		player.Character.PrimaryPart.CFrame = elevator.TeleportIn.CFrame
		elevatorEvent:FireClient(player, elevator)
		if not countdownRunning then
			RunCountdown()
		end
	end
end)

elevatorEvent.OnServerEvent:Connect(function(player)
	local isWaiting = table.find(playersWaiting, player)
	if isWaiting then 
		table.remove(playersWaiting, isWaiting)
	end
	
	mapgui.Title.Text = #playersWaiting .. "/" .. config.MaxPlayers.Value
	
	if player.Character then
		player.Character.PrimaryPart.CFrame = elevator.TeleportOut.CFrame
	end
end)

i have the same problem now, this maybe problem with roblox. i can’t use reserved servers, for how long this error there? , i have 403 forbidden error for my own place that is published, soo this is 90% roblox

1 Like

Hey! maybe this video link helps out Game Lobby Elevators - Tower Defense Tutorial #20 - YouTube at 54:13 it shows reserved server teleport if this still dont works please show this error to someone with high coding experince

1 Like

Yeah, but the problem is, there no problem with teleport there is problem with only this:

local code = tp:ReserveServer(14397856095) 

place id is correct, everything is published, settings are correct, and it gives error
``

HTTP 403 (Forbidden)

``

1 Like

Have you tried using this as the place ID?

Go to your experience’s page on Roblox, then click Configure Place, and look at the page URL. It should be the second string of numbers, instead of the first.

Also, why are you looking through a folder called “Players” in ReplicatedStorage for your list of players to teleport? I’d recommend just using game.Players:GetChildren() for your players value (however remember to do this before you teleport your players, instead of at the start of the script).
(local Players = game:GetService("ReplicatedStorage"):WaitForChild("Players"))

Also, forgot to mention, have you turned on third party teleports in game settings?

i told, i turned on everything, and place id is coppied from asset manager because it’s seccond place

you show that local code equals to tp:ReserveServer can you try with TeleportService instead of tp?

1 Like

i using everything on server
and yea i can change tp to TeleportService, it’s only name

Yes, I’ve done that on both games.

and btw add teleport service at start of the script

local TeleportService = game:GetService("TeleportService")
1 Like

yea i added it, and in game something told me that place is restricted, but it’s public

Try changing this

TeleportService:TeleportAsync(4972532928, Room, Enum.TeleportType.ToReservedServer)

to this:

TeleportService:TeleportAsync(4972532928, game.Players:GetChildren(), Enum.TeleportType.ToReservedServer)
1 Like

yea, but teleprot async have to have options that is object, not enum

If you have a different problem, you can open your own topic before mixing up everything :wink:, thank you.

2 Likes

xd, i don’t know this is about teleport async, let’s fix two problems at once, because you reserving server too

instead of writing place id can we just write a code like this?

local placeId = 4972532928
TeleportService:TeleportAsync(placeId, game.Players:GetChildren(), Enum.TeleportType.ToReservedServer)
1 Like

oh yeah i totally forget about that

but then we get error about object cannot cast to value, because enum is value and you need teleport options that is instance.new()