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
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.
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)
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