Capture Points using OnTriggerEnter

Hello, I am making a simple RTS game, and one of the main mechanics of it is to capture and hold control points, which give you resources as you hold them. At the moment, I am trying to use OnTriggerEnter, and I am hoping it will be called when a unit’s collider enters the radius of the collider of the control point. When a unit enters the point, I want the sprite of the child object to change to that team’s color after about 5 seconds. I have not been able to get this to work, here is my code:

    public float fliptime;

    BoxCollider Boxxy;
    float CapRadius;

    public Sprite RedPoint;
    public Sprite GreyPoint;
    public Sprite BluePoint;

    public CPSpriteChanger CPSC;

void Start () {
        Boxxy = GetComponent<BoxCollider>();
        CapRadius = Boxxy.size.x;
        }
private void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag == "BlueUnits")
        {
            float CaptureTime = Time.time + fliptime;

            while(Vector3.Distance(gameObject.transform.position, other.transform.position) > CapRadius)
            {
                if(Time.time > CaptureTime)
                {
                    
                    CPSC.ChangeSprite(BluePoint);
                }
            }
            
        }
    }
//below here is part of a separate script, what CPSC is pointing to. 

    SpriteRenderer SRend;

    void Start () {

        SRend = GetComponent<SpriteRenderer>();
	}
    public void ChangeSprite(Sprite S)
    {
        SRend.sprite = S;
    }

Any help would be appreciated.

@tobinp93

So I am guessing you are making a 2d game. Mainly because you are using sprites. So it should help if you use 2d game physics and other things accordingly like so:

[Header("Name Of The Red Team(Player Must Have This Tag)")]
public string redTeam = "Red";

[Header("Name Of The Grey Team(Player Must Have This Tag)")]
public string greyTeam = "Grey";

[Header("Name Of The Blue Team(Player Must Have This Tag)")]
public string blueTeam = "Blue";

//Sprites To Change The Capture Point To
public Sprite redCapColor;
public Sprite greyCapColor;
public Sprite blueCapColor;

[Header("Time It Takes To Capture The Point")]
public float CaptureTime = 5;

[Header("Radius In Which The Point Is Capturable")]
public float CapRadius = 1;

//Time the team has held the capture point
public float redCapture;
public float greyCapture;
public float blueCapture;

//Empty Collider Array
Collider2D[] colliders;

//Radius to hold the statuses of the teams
bool redCaptureStatus;
bool greyCaptureStatus;
bool blueCaptureStatus;

void Start()
{
    //Both of the teams capture status at the start are false
    blueCaptureStatus = false;
    greyCaptureStatus = false;
    redCaptureStatus = false;

    //Both of the teams capture times are 0 at the start
    redCapture = 0;
    blueCapture = 0;
    greyCapture = 0;
}

void Update()
{
    //Get the colliders inside the origin of this gameobject and the radius(CapRadius)
    colliders = Physics2D.OverlapCircleAll(transform.position, CapRadius);

    //If there is a collider detected within the radius(CapRadius)
    if (colliders.Length > 0 && colliders != null)
    {
        //Then loop through the colliders
        for (int i = 0; i < colliders.Length; i++)
        {
            //Check if the Team Counts are not equal to each other
            if (TeamCount(blueTeam, colliders) != TeamCount(redTeam, colliders) || TeamCount(redTeam, colliders) != TeamCount(blueTeam, colliders))
            {
                //If the collider within the circle is of the blue team
                if (colliders*.tag == blueTeam)*

{
//And the teams capture time is less than the time it takes to capture
if (blueCapture < CaptureTime)
{
//Add to the teams capture time
blueCapture += Time.deltaTime;
//If the enemy teams capture time is greater than 0
if (redCapture > 0)
{
//Subtract the enemy teams capture time
redCapture -= Time.deltaTime;
}
//If the enemy teams capture time is greater than 0
if (greyCapture > 0)
{
//Subtract the enemy teams capture time
greyCapture -= Time.deltaTime;
}
}
//Else the teams capture time is greater than the capture time
else
{
//Set the capture status of the team to true and the enemys team to false
blueCaptureStatus = true;
redCaptureStatus = false;
greyCaptureStatus = false;
}
}
//Check if the Team Counts are not equal to each other
else if (colliders*.tag == redTeam)*
{
//If the collider within the circle is of the red team
if (redCapture < CaptureTime)
{
//Add to the teams capture time
redCapture += Time.deltaTime;
//If the enemy teams capture time is greater than 0
if (blueCapture > 0)
{
//Subtract the enemy teams capture time
blueCapture -= Time.deltaTime;
}
//If the enemy teams capture time is greater than 0
if (greyCapture > 0)
{
//Subtract the enemy teams capture time
greyCapture -= Time.deltaTime;
}
}
//Else the teams capture time is greater than the capture time
else
{
//Set the capture status of the team to true and the enemys team to false
redCaptureStatus = true;
blueCaptureStatus = false;
greyCaptureStatus = false;
}
}
//Check if the Team Counts are not equal to each other
else if (colliders*.tag == greyTeam)*
{
//If the collider within the circle is of the red team
if (greyCapture < CaptureTime)
{
//Add to the teams capture time
greyCapture += Time.deltaTime;
//If the enemy teams capture time is greater than 0
if (blueCapture > 0)
{
//Subtract the enemy teams capture time
blueCapture -= Time.deltaTime;
}
//If the enemy teams capture time is greater than 0
if (redCapture > 0)
{
//Subtract the enemy teams capture time
redCapture -= Time.deltaTime;
}
}
//Else the teams capture time is greater than the capture time
else
{
//Set the capture status of the team to true and the enemys team to false
greyCaptureStatus = true;
redCaptureStatus = false;
blueCaptureStatus = false;
}
}
}
}
}
//If the teams capture status is equal to true then set the color of our capture point accordingly
if (redCaptureStatus == true)
{
GetComponent().sprite = redCapColor;
}
if (blueCaptureStatus == true)
{
GetComponent().sprite = blueCapColor;
}
if (greyCaptureStatus == true)
{
GetComponent().sprite = greyCapColor;
}
}
//Uses Team Tag and Collider Array To Find The Team Count
int TeamCount(string tag, Collider2D[] colliders)
{
//Set the count to 0
int count = 0;
//Loop through the colliders array
for (int i = 0; i < colliders.Length; i++)
{
//If the collider’s tag within the array equal the team tag
if (colliders*.tag == tag)*
{
//Add to the count
count += 1;
}
}
//Then return the complete count of the tag within the array
return count;
}