:TeleportAsync() + ReservedServers are driving me nuts


Code:

game.ReplicatedStorage.JoinReservedServer.OnServerEvent:Connect(function(player,PrivateServerID)
	local ReservedServer = TeleportService:ReserveServer(GameID)
	local teleportOptions = Instance.new("TeleportOptions")
	print("Private server: " .. PrivateServerID)
	teleportOptions.ReservedServerAccessCode = PrivateServerID

	game:GetService("TeleportService"):TeleportAsync(GameID,{player},teleportOptions)
	game.ReplicatedStorage.CreateNewServer.ServerIsLaunching:FireAllClients()
end)

Im trying to make a system where u can join a server on the server list. The issue is that the servers on the list are reserved servers which means they’re basically private and they need a verification code to join.

What im currently doing is receiving the PrivateServerId from all the servers, and whenever they try to join i use the PrivateServerID for ReservedServerAccessCode. But unfortunately that refuses to work

4 Likes

The error message states that the place you are trying to teleport to is private?

4 Likes

Yup, it’s a reserved server, which to my knowledge, is the only way to send a group of players to a newly created server. However im struggling to make it so players can join AFTER its been created.

3 Likes

Open the place and publish it (This worked for me when I had this error)

If that doesnt work, let me know

4 Likes

This is happening in the published version.

1 Like

Wait, are you using different places?
image

Or is it just one place?

3 Likes

Its two places, The home place is a lobby, the second place is the actual game.

1 Like

Hm, are you sure ‘GameID’ is the correct ID?

2 Likes
local TeleportService = game:GetService("TeleportService")

game.ReplicatedStorage.JoinReservedServer.OnServerEvent:Connect(function(player, PrivateServerID)
    -- Assuming you've already reserved the server during game initialization
    local ReservedServer = TeleportService:GetReservedServerByCode(PrivateServerID)
    if ReservedServer then
        local teleportOptions = Instance.new("TeleportOptions")
        teleportOptions.ReservedServerAccessCode = PrivateServerID

        TeleportService:TeleportAsync(GameID, {player}, teleportOptions)
    else
        warn("Invalid or expired ReservedServerAccessCode:", PrivateServerID)
    end
end)
2 Likes
local AccessCode, id = TeleportService:ReserveServer(GameID) --Getting the reserved server Code and ID

TS:TeleportToPrivateServer(GameID, AccessCode, {player}) -- Teleports the player to the Reserved server using the AccessCode

This should work

2 Likes

GetReservedServerByCode is not a valid member of TeleportService

1 Like

No it did not, However i did figure it out using the solution from this post Can i get acces code from reserved server? - #10 by mistr88

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