Locking a Server

Here’s my issue:

Lobby teleports player to a Place1

Place1 receives player. Once enough players are in the server, or a pregame timer limit is reached, then Place1 stops recieving players. But I don’t want to just kick any players who are trying to join, I want Lobby to know if a Place1 server is already either full or out of pregame to decide if they can send a player with them.

1 Like

I don’t know about the pregame timer limit, but I do know how to kick players when enough players are in the server.

You’ll have detect how many players are in a place, and if it reached the max count, then you’ll kick any player that tries to join.

The sample script below might work. I have not tested it:

-- Place this script in Place1

local Players = game:GetService("Players")

local maxPlayers = 12 -- Change to your what best fits for your game

Players.PlayerAdded:Connect(function(player)
	for i, player in ipairs(Players:GetPlayers()) do
		if #Players:GetPlayers() == maxPlayers then -- Use the length operator to detect how many players are in the server
			-- Code here
		end
	end
end)
2 Likes

I would recommend using MemoryStoreService or at least MessagingService, and reserving a server for Place1. This way a lobby can keep sending players to Place1 until its full, and Place1 can send back information to tell the lobby it came from that it is done.

4 Likes

Didn’t the guy just say he doesn’t want to kick any players who are trying to join?

You’re right. I can’t believe I didn’t see that.

Thanks for pointing it out. I edited my script :slight_smile: