I’m currently working on a matchmaking system, in which groups of players are put into reserved servers created using :TeleportAsync(). I want the servers created to be public rather than reserved, but the players MUST be teleported to new lobbies, not pre-existing ones. Is it possible to create public lobbies in this manner, or do I have to reserve them in order to do so?
i think you can just grab the reservedserverid and store it in a datastore so that all servers have access to them? i think that’s what you want but I’m not sure.
local DataStoreService = game:GetService("DataStoreService")
local TeleportService = game:GetService("TeleportService")
local AccessCodes = DataStoreService:GetDataStore("ServerAccessCodes")
local placeId = game.PlaceId
local playersToTeleport = {}
local TeleportOptions = Instance.new("TeleportOptions")
TeleportOptions.ShouldReserveServer = true
local success, data = pcall(function()
return AccessCodes:GetAsync("PublicAccessCode")
end)
if success and data then
TeleportOptions.ReservedServerAccessCode = data.ReservedServerAccessCode
end
local success, result = pcall(function()
return TeleportService:TeleportAsync(placeId, playersToTeleport, TeleportOptions)
end)
if success and result then
AccessCodes:SetAsync("PublicAccessCodes", {ReservedServerAccessCode = result.ReservedServerAccessCode, PrivateServerId = result.PrivateServerId})
end