So basically I want to make a game where you could have different parties or servers. Someone would initially host a reserved server and would get a code. then anybody who knows that code would be able to join there game!
the code I am using right now is this:
--code for Teleporting the player who creates the reserved server:
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
game.ReplicatedStorage.CreateServer.OnServerEvent:Connect(function(Player)
local code = TS:ReserveServer(game.PlaceId) -- Returns a code
local players = Players:GetPlayers() -- Get a list of all players
TS:TeleportToPrivateServer(game.PlaceId,code,players)
end)
the only problem is the code that you use to join the game is WAY TOO big.
Also, I don’t know if a private server is the same or very related to a reserved server, I don’t know how I could shorten the code and be able to display and use the code in a public server.
Sorry if this isn’t clear…
What you need to do is create a variable that is equal to a table, then insert those players into the table. Finally, in the third parameter, change Player to your table name.
I also suggest that you change game.placeid to an actual id as it won’t work
–code for Teleporting the player who creates the reserved server:
local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
game.ReplicatedStorage.CreateServer.OnServerEvent:Connect(function(Player)
local code = TS:ReserveServer(game.PlaceId) -- Returns a code
local players = Players:GetPlayers() -- Get a list of all players
for i, v in pairs(players) do
TS:TeleportToPrivateServer(game.PlaceId,code,v)
end
end)