I'm trying to see how many players are on a team, can someone create a line/if then/function for a script?
My attempt:
if Teams.Alive.GetPlayers == 1 then
I am not sure how the team service works with everything, but this script checks how many children are in a instance
local count = 0 for i,v in pairs("DirectoryToThing"):GetChildren()) do count = count + 1 end print(count) --instead of print you could do whatever you want with the total
Here is a function the counts how many players are in the given team it loops through all the players and it check if the player is in the given team if so it add 1 number in to a variable then it returns it
local AliveTeam = game.Teams.AliveTeam -- the team function GetAmountOsPlayersInTeam(Team) local Total = 0 for _,Player in pairs(game.Players:GetChildren()) do if Player.Team == Team then Total += 1 end end return Total end wait(4) -- wait for player to load in print(GetAmountOsPlayersInTeam(AliveTeam)) -- just to test -- you can use the function in another way if GetAmountOsPlayersInTeam(AliveTeam) > 0 then print("We have more then 0 playe in the game") end
i hope this helps you