Help with seeing who owns a Capture Point

I’m making a Capture Point System and I don’t know how I would get what Team has more players on the point. I have a table of every player in the area, I just don’t know how I would know what team has more without making a table per every team but theres no way to do that programmatically

How about a table for every single capture point that’ll log the players that step into it and step out of it, when a player steps in check if they arent already on that capture point then put them inside of it and then check what team they are on and update the respective team amount

local capture_a_red_team = 0
local capture_a_blue_team = 0

local capture_a_logs = {}

if not capture_a_logs[player] then
    capture_a_logs[player]  = true
      
    if player.isOnRedTeam() then
        capture_a_red_team += 1
    else
        capture_a_blue_team += 1
    end
end

when a player steps out of it youd check if they are inside of the capture point, and if they are remove them and check there team again and decrease the amount in their respective team amount

but the amount of teams is modular, is there a way to do that programmatically?

What do you mean the amount of teams is modular, like as in there wont be exactly 2 teams every time?

yes, there could be 2, there could be 4

Hmmmm you could possibly do something like this

So when the round or whatever starts youd create a table for a capture point thatll hold the player inside of it and then a table for the teams number of players at that capture point, and then just initialize it all too 0, then when a player enters check if they arent already inside of there and then get the team they are on and then use that to get the index of the teams inside of numberOfTeamsAmountAtCaptureA and then increment it

The getTeam function is just a made up function to just show you a high level overview of what you could do

-- Setup
local numberOfTeams = 4

local capture_A = {}

local numberOfTeamsAmountAtCaptureA = {}

for i = 1, numberOfTeams do
   numberOfTeamsAmountAtCaptureA[i] = 0
end

-- When a player enters a capture point
if not capture_A[player] then
   capture_A[player] = true
   local playersTeam = player.getTeam() -- returns a number
   numberOfTeamsAmountAtCaptureA[playersTeam] += 1
end

I don’t really get this too well, why is it being indexed to 0?

does this just put the index of every team into a table and count which number appears the most?

He sets the points to 0 for every i team there is. So if there’s 8 teams then those 8 teams get their value set to 0