Hello, I’m making a game where there are 2 places, the menu and the main place. In the menu you can choose which map you want to play in, and the game scans every server in the main place and checks if they have the map you want, however if there is no server with your desired map, it will create a new public server and teleport you to it. I know how to do the server check, but not the server creation. How would I achieve this?
simply teleport that player to the place using game:GetService("TeleportService"):Teleport(gameplaceid, player)
roblox will crate automatically a new server if there is none available
The problem is if there is a server available roblox will teleport the player to that server regardless of if the map in said server is the map the player wants to join.
I think this could help you: MessagingService
The idea is that you could send message to all servers and they would automatically respond with current map which you could handle in your menu
MessagingService is a bit outdated and limited, especially seeing as it has a max usage for the entire experience (not just per-server), as shown here:
MemoryStoreService should be used instead.
Also, what you’ll want specifically is TeleportToPlaceInstance.
I don’t think TeleportToPlaceInstance
would create a new server.
I’ve heard of Universe Scripts and someone mentioned they could create servers. Are they still coming to roblox because I took a look at the roadmap and they aren’t there anymore
That is where scripting comes in. You can use the MemoryStoreService to keep an updated list of all active servers with whatever information you want (including their JobId), then you can use TeleportToPlaceInstance to teleport to any of those specific servers. If no list is available or nothing relevant is found, you can just perform a normal teleport instead.
I see. Thanks for the help!
One question, if I use a normal teleport will it have a chance of teleporting the player to a server with a map they don’t want?
That could potentially happen. That’s why ReservedServers are better for this sort of thing. Or you could just create a place for each map and then teleport to those places. That would save a lot of coding time.
Good idea! I would use InsertService to insert everything so I don’t have to copy and paste the code!
I believe there’s already a way to sync scripts across the experience. I’ve never used it before, but it might be worth checking out. InsertService will probably work too, but just note that it might not execute scripts at the very start of the game. Because of this, you’ll want your code to expect some players to already exist by the time the script starts to execute.