Something like this should work?
Basically, your problem is that your event fires when ANY humanoid dies. You need to keep track of how many there are, decrement a counter when somebody dies, and when there are 0 remaining, the team is eliminated.
01 | function checkEliminated(counter, team) |
02 | if counter.Value < = 0 then |
08 | for _, team in pairs (game:GetService( "Teams" ):GetChildren()) do |
09 | if team:IsA( "Team" ) then |
11 | local aliveCounter = Instance.new( "IntValue" , team) |
12 | aliveCounter.Name = "PlayersRemainingCount" |
15 | local teamPlayers = team:GetPlayers() |
16 | aliveCounter.Value = #teamPlayers |
18 | for _, p in pairs (teamPlayers ) do |
19 | if p.Character and p.Character:FindFirstChild( "Humanoid" ) then |
21 | local conn = p.Character.Humanoid.Died:Connect( function () |
22 | aliveCounter.Value = aliveCounter.Value - 1 |
24 | checkEliminated(aliveCounter, team) |
28 | aliveCounter.Value = aliveCounter.Value - 1 |
29 | checkEliminated(aliveCounter, team) |