How do I check when player count changes?

I’m trying to fire this event whenever the player count increases or decreases so it updates correctly.

The event works fine and works as intended. I’m just having a bit of trouble checking when players join/leave

As far as I know, there aren’t any tutorials on this.!

local playersget = game.Players:GetChildren()
if #playersget >= 3 then
	game.ReplicatedStorage.RoundStatus.WaitingForPlayers:FireAllClients()
end

^ This is my current code

Just use game.players.playeradded and the same with playerremoved

1 Like
game.Players.PlayerAdded:connect(function()
    local playersget = game.Players:GetChildren()
    if #playersget >= 3 then
        game.ReplicatedStorage.RoundStatus.WaitingForPlayers:FireAllClients()
    end
end)

game.Players.PlayerRemoving:connect(function()
    local playersget = game.Players:GetChildren()
    if #playersget >= 3 then
        game.ReplicatedStorage.RoundStatus.WaitingForPlayers:FireAllClients()
    end
end)
1 Like