Is it possible to block random player joins on a server?

The game I have consists of 8 tycoons per server. I’d like to make the server size 24 players so that a tycoon owner can invite up to two friends onto their team to use their stuff with them. I dont, however, want any new player to join a server and not have an open tycoon to claim. I am aware that there is a feature to reserve player slots in a server to friends, but I am wary of those friends joining and taking up the other spots (i.e. 3 teams fill up with 3 players each, making 9 players. Nobody else can join the server because only friend slots remain, resulting in 5 unused tycoons).

Ideally, the best way to do this would be via script. Observe the tycoons, and once all tycoons are claimed (or the number of unassigned players equals the number of unclaimed tycoons) then random player joins would be diverted to other servers. I do not know if this is something i can do, but if anyone knows I would love to find out!

1 Like

I’m pretty sure that this would be possible!


In order to tell if a join was “random” (e.g. the player who joined did not join as a result of being invited or is not friends with anyone else in the server) there are at least 2 different options I am aware of:

  • Player:GetJoinData() - This returns a whole bunch of useful information inside of a table, with keys such as ReferredByPlayerId (as well as LaunchData) being able to immediately indicate if the player was invited to the server.

    • When a player joins the game (detected via Players.PlayerAdded), perform a check on the tycoons to see if there are still unoccupied tycoons / other criteria that you define. If not, check if ReferredByPlayerId has a value stored; if it does, someone invited them there so they can stay. I’m pretty sure that LaunchData would work in a similar way (empty by default) but I don’t know for sure; you can read more about it on this Roblox Creator Hub Guide if interested.

  • Player:IsFriendsWith() - After inputting a UserId into this method, it’ll return true if the player is friends with that user and false if they are not.

    • If :GetJoinData() did not have anything that indicated that the player was invited to the server, then you could consider looping through every other player in the server to see if this returns true. If it returns true once for ANY other player in the server, then the player who just joined can stay since it was not a “random join”. Otherwise, if it returns false for every player, that means that the player who joined is not friends with anyone else there.

      • Disclaimer: The documentation states that calling this “sends a request to the Roblox website”, although it does not specify if this is rate-limited (e.g. can only be called a certain number of times within a given timeframe). Since it does not have async added to the end of it, that leads me to believe that there is not a rate limit, but that is just an inference, so be wary about it potentially failing in-game. Would be useful to run tests of this in a live server prior to implementing it into your main game.

  • Alternatively, there are other, similar methods that can be used to check who a player is friends with, although these are rate-limited and they return an entire list that the script would need to review rather than keeping it limited to directly and individually checking friendship status among players in the server through Player:IsFriendsWith()

    Oh, and the topic that I saw these referenced from was one that might be relevant to your use case, so I’ll link it here along with the Roblox Creator Hub documentation pages, just in case you want to review the post, too:

  • Player:GetFriendsOnline()

  • Players:GetFriendsAsync()


When it comes to teleporting the player to a random server within the same game, if you don’t make use of the Open Cloud and HttpService, you could utilize the MessagingService to achieve that (unless you used a workaround of teleporting to a separate place within the same universe, then teleporting the player back to the main place, although that wouldn’t guarantee that they are placed into a new server).

I know basically nothing about the MessagingService, but here are some resources I found regarding gathering a list of all active servers for a game:

2 Likes

This is useful! but alas, there is no way to turn off random joins directly? This method you mentioned would still work, it just may potentially double loading time as the player will have to join, get diverted to another server, and then join that one

1 Like

As far as I am aware, that isn’t possible unless you create a custom system of sorts where the starting place for the game is a “lobby” and then every server is created manually through TeleportService:ReserveServer() so that you can control the accessibility of every server.

At least that’s how I think that would work; games like Breadwinner World make use of the structure that I am thinking of. It doesn’t allow you to directly join another player via the website (it says that the place is “restricted” or something along those lines). When you press play on the page of the game, the player temporarily views a loading screen in an initial server / lobby, and then very quickly afterwards, it directly teleports the player into a specific server (which for the case of this game, is whichever server is hosting the persistent world / map where you were the last time you played the game).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.