ReserveServer is not working

Hello, Recently I was trying to do script, that will ReserveServer for my game because of lobbies the player can join etc.

Script that recieves event:

local JoinServer = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("JoinServer")
local JoinServer_server = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("JoinServer"):WaitForChild("JoinServer_Server")
local TeleportService = game:GetService("TeleportService")

local PlaceIdServer -- PlaceID Number

local function teleportPlayerToServer(players)
	local reservedServerCode = TeleportService:ReserveServer(PlaceIdServer)
	TeleportService:TeleportToPrivateServer(PlaceIdServer, reservedServerCode, players)
end

JoinServer_server.Event:Connect(function(lobby_id, players: {})
	teleportPlayerToServer(players)
end)

Script that sends event: (other script)

-- its not full script but its only what it does when it sends the event
createEvent.OnServerInvoke = function(player, lobbyData: {})
    local temp_id = generateID(lobbyData) -- generateID Function is generating tempID of the lobby, but its useless for now.
    JoinServer_Server:Fire(temp_id, {player})
end

Both these scripts are Server Scripts!

When i join the server and tries to connect to that server, it shows me this on screen:
image

The Place is subplace of the game.

And I dont know how to fix it. Can anyone help me?

1 Like

Try using TeleportService:TeleportAsync() with teleporting options as it allows you to make the reserved server as you teleport.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.