How to restrict people to join

How could I do that if the game has a maximum of 7 players, but when something happens, even if there are no 7 players, the next person who enters will not be able to enter and they will automatically be kicked out

You could simply just add a script that would complete this function, either local or ServerSided works.

game.Players.PlayerAdded:Connect(function(plr)
wait(2) -- Change that to your own time or remove it (I would suggest to have a waiting time)
plr:Kick("Server has been locked, you're no longer able to join this server.")
end)
1 Like

Wrong. This just waits 2 aeconds to kick players who joined no matter what lol.

1 Like

I did not clearly understand your question but I tried my best.

local players = 0
game.Players.PlayerAdded:Connect(function(plr)
if players >= 7 then
plr:Kick("Max")
else
players += 1
end
end)
1 Like

bro it’s just an if statement lol, he is saying the basics

1 Like