Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Retrive a List of all Private Servers created?

Asked by 4 years ago
Edited 4 years ago

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?

0
I don't know if there is a legitimate way, but record all the private servers created in a list and then when you want to get the full list, use Messaging service to get more lists from all the other servers and then you can combine the lists to get one whole script with all the private servers. Hope this helps! sheepposu 561 — 4y

1 answer

Log in to vote
1
Answered by
VitroxVox 884 Moderation Voter
4 years ago

A good source

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
Ad

Answer this question