And i need to make something with private servers soo you can create your own server in lobby (it will be playing in Main Game you just create it in lobby) and then share code with friends to make them join your reserved server. Any idea how to make this work?
I´m not asking for code, i just need to know way to do it, i know there is some form of UUID of each server but i dont know how to connect players to it and check if it is correct (if that server exist)
You can use TeleportService:Teleport() to teleport a player to the main game and then in the main game use TeleportService:ReserveServer() to send the player to the private main game.
There are multiple ways to do that. I would prefer these two:
Generating a code (like a password) which the player can put in the TextBox and the script will detect the code and send them to the wanted server.
Using the given code when you create a reserved server which is long and can be difficult to use.
If you do it like the first method, you should use DataStoreService to save the code. You should use the code as the key since it will be easier to manage it.
I honestly dont understand this
I looped this for each play that had the server code that I randomly generated and it gave me the error, Can I not create my own codes?
if Command == "Start" then
game.Lighting.HostNumber.Value = game.Lighting.HostNumber.Value - 1
for i, Players in pairs(MyPartyData:GetChildren()) do
local Name = Players.Value
print(Name)
if Name ~= "" then
print(Name)
local Player = game.Players:FindFirstChild(Name)
local code = TS:ReserveServer(ServerCode.Value)
TS:TeleportToPrivateServer(game.PlaceId, code , Player)
end
end
end