I'm trying to make something so if too many people get on it shuts down the server, to test it I put it for 2 people.
local amount = 0
game.Players.PlayerAdded:connect(function(player)
amount = amount + 1
print(amount)
end)
game.Players.PlayerRemoving:connect(function(player2)
amount = amount - 1
print(amount)
end)
while true do
if amount == 2 then
Instance.new("Message",Workspace).Text = "Too many people... Shutting down server"
wait(2)
for i,v in pairs(game.Players:GetChildren()) do
v:Remove()
end
end
end

2 comments
Yeah, but i'm mainly trying to test my scripting ability and trying to learn more by trying to get this to work
k