Make servers unjoinable when 10 players join

This will teleport only the 10th player to a different server which I’m not sure is what you want… is this in the main server or the private one?

This would be in the Map, then it would TP the player to the hub. What do you mean by it would TP the 10th player?

You could do this in the private servers, but people can’t join private servers unless the hub specifically sends them to it. If you’re using messaging service and tell the hub when the private server is full, then just don’t send players to that server anymore (make a new one) and this should work fine. You could check if the number of players is more than a certain number when a player joins but then players will just be being teleported back and forth between servers! :stuck_out_tongue:

So wait, is this system kind of how games like Eviction Notice and Survivor code their matchmaking? I’m just trying to figure out the similarities, and because I find their system never bugs up or anything. Sorry for asking so many questions.

1 Like

One more question, how can I create/check for private servers and their player counts?

This is where the messaging service comes in; by sending each private servers player count to the main hub, the hubs can check which servers are available and therefore decide whether they should create a new private server or send the player to an existing server, using TeleportService.

I ran through the layout of the code on this post:

Ok, so I’m curious, I’m kind of clueless right now, with multiple things:

  1. I don’t really understand the concept of MessagingService, and how to Message other servers.
  2. I don’t know how to make a Private Server.

Sorry, I’m just not getting it right now. If you want to try explaining it again, you can, if not, that’s fine too. :expressionless:

Okay, well you’ll have to do a little bit of your own research too, and once you have researched a bit have a go at making this system that we’ve discussed! :smiley:

MessagingService means you can broadcast a message and listen for messages. Imagine someone shouting, but only a select few people are listening for their shout.

In the same way, a server can “shout” something by calling MessagingService:PublishAsync(), and any servers that are “subscribed” (listening) for that shout will run the function associated. They can listen for a shout with the method MessagingService:SubscribeAsync().

This is useful because you can “shout” things with a specific key, such as a name, and then include information sent along with the shout. If a server is listening for the shout with that specific key, it can run a function and use the extra data sent along with it.

In my example earlier, one server listens for the shout with the key “Test”, and will print the data that gets sent with that shout. The other server sends a shout with the key “Test” and the extra data of the players name when a player joins. Therefore the first server gets a message with the data being the player’s name from the other server.

More info about MessagingService, Using MessagingService: a community tutorial and the developer hub: Messaging Service.

Check out the developer forum on sending players to private servers etc; TeleportService API page, ReserveServer Method and TeleportToPrivateServer Method.

Let me know if you need any other help, but you should be able to start off using TeleportService and MessagingService after looking at these pages or elsewhere on the forum (maybe there are more tutorials, if I didn’t find them). Hope it all goes well! :slight_smile:

Alright well, I’m going to take a quick break, just clear my mind a bit, then I’ll come back and research some stuff, and get back to you, sounds good? Thanks so so so so so so so much for the help today! :slight_smile:

1 Like

Hey there! So while experimenting and researching, I came up with an idea: I could just teleport the player with a loading screen that says that the server was full! Thanks for the help, but I ended up needing just to stop and think! Sorry about the waste of time, and I’ll let you know if I need anything else. :slight_smile:

I don’t see why you’d create a “Numb” value when you could easily just do #game.Players:GetChildren()