-- Hitting players makes them join your team.
-- Once everyone is on the same team the game ends.
if not event.entity:getPlayer() then
-- Make sure the tagger is a player
if (not event.fromEntity or not event.fromEntity:getPlayer()) then
local attackerTeam = TeamService.getTeam(event.fromEntity:getPlayer())
-- Check that all teams besides the attackerTeam are empty
-- If so give win to attacker team
for i, team in ipairs(TeamService.getAllTeams()) do
if (team == attackerTeam) then
-- If another team has players the game is not over
if #team:getInGamePlayers() > 0 then