Removing and Adding gameobjects to an array upon collision

Hello.
I’m attempting to do something that might be a bit difficult.
I’m making a 2D game where the player has 2 child objects attached to it. They both have a collider attached to them and are positioned to the left and to the right of the player, outside the camera.

The right one enables the MeshRendereron the floor(which is made of boxes) and the left one disables the MeshRenderer.
I’m attempting to optimize this script so it also destroys these objects but I can’t.
because the player adds all of them to an array upon starting the game.

In the Start() I assign the PlayerScript to a variable called playerScript

private PlayerScript playerScript;

void Start()
{
	playerScript = GetComponent<PlayerScript>();
}

But I’m unable to reach the array and modify it for some reason.

if(other.CompareTag("Floor"))
{
	if (renderObject == true)
	{
		//Add it to the array
	}
	else
	{
		//Remove it from the array
	}
}

if I start typing playerscript.RedFloorArray nothing show up.

Thanks for reading

In PlayerScript you can simply create a function like this one you are trying to wrote outside (i assume that the RedFloorArray is an array of GameObject):

public void AddFloorArray(){
 GameObject child = GameObject.FindGameObjectsWithTag("Floor") // or you can pass it as parameter
 RedFloorArray.Add(child);
}

public void RemoveFloorArray(){
 for(int i = 0; i<RedFloorArray.length; i++){
  obj = RedFloorArray*;*

if(obj.CompareTag(“Floor”)){
RedFloorArray.RemoveAt(i);
}
//maybe → Destroy(obj);
}
}

public void RemoveFloorArray(GameObject child){
for(int i = 0; i<RedFloorArray.length; i++){
obj = RedFloorArray*;*
if(obj.name.Equals(child.name)){
RedFloorArray.RemoveAt(i);
}
//maybe → Destroy(obj);
}
}
So you can call this function outside without problem:
OnCollisionEnter(Collision col){
playerScript.RemoveFloorArray(col.gameObject);
}