Affect every object in array.

Hello, What I’m trying to do is to disable the ball sprite renderer when the player grabs it but I have multiple players in an array list but when I run the game ball sprite renderer disabled only with the last element it doesn’t work with other elements

public List<GrabController> grabScript = new List<GrabController>();
public SpriteRenderer spriteRenderer;


void Update()
    {
        for (int i = 0; i < grabScript.Count; i++)
        {
            if (grabScript*.isGrabed == true)*

{
spriteRenderer.enabled = false;
}
else
{
spriteRenderer.enabled = true;
}
}
}

Hi @hamoo7dfuad,

ok, solution could be bool returning value depending from checking values in List… in Update():

spriteRenderer.enabled = whatShouldBeBallStatus();


Below add new bool:

bool whatShouldBeBallStatus()
{
for (int i=0; i< grabScript*.Count;i++)*

{
if (grabScript*.isGrabed == true) return false;*
}
return true;
}
Hope will do! Let me know! Also in case that someone will have similar issue remember to edit your initial question.