Im making a game where you Have a GUI where you can create your own server or join others with this script that works perfectly fine to create a server.
I want to get a list of avaible Servers using the ReserveServer and but it on the players Gui.
Script to Create the Server WORKS
local TeleportService = game:GetService("TeleportService") local placeId = 000000000000 game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,Type) if Type == "Create" then local player = game.Players[""..plr.Name..""] local access = game:GetService("TeleportService"):ReserveServer(placeId) game:GetService("TeleportService"):TeleportToPrivateServer(placeId,access,{player}) end end)
Script to Join Server DOESNT WORK
local TeleportService = game:GetService("TeleportService") local placeId = 0000000 game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,Type) if Type == "Join" then local player = game.Players[""..plr.Name..""] local access = game:GetService("TeleportService"):ReserveServer(placeId) game:GetService("TeleportService"):TeleportToPrivateServer(placeId,access,{player}) end end)
Is there a way i can retrieve a List of all the avaible servers?
And if that doesn't work you could log the servers as when the user creates a server it adds a value to a folder or just adds to a table
Example
local servers = {} local TeleportService = game:GetService("TeleportService") local placeId = 000000000000 game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,Type) if Type == "Create" then local serverinfo = table.insert(servers,{servername=plr.Name.."'s server",servertype=Type}) local player = game.Players[""..plr.Name..""] local access = game:GetService("TeleportService"):ReserveServer(placeId) game:GetService("TeleportService"):TeleportToPrivateServer(placeId,access,{player}) end end)
To get the lists you would just do
for _,serverlists in pairs(servers) do print(serverlists.servername,serverlists.servertype) end