How to disable scripts inside objects found with tag

Hello,

I’m trying to find objects with a certain tag then disable one specific script inside those objects but cannot manage to make it work so far.

Here is what I was trying lately:

var blockfall : gameObject.FindGameObjectsWithTag("Block").GetComponent(BlockFall).
enabled;
blockfall = false;

Can someone explain me what is going on here and why I cannot do such a thing ?

Thank you very much! :slight_smile:

Phil

First, FindGameObjectsWithTag returns a list of objects.

Second, you need to loop through all those objects.

Third, you need to get the BlockFall component from each object and set its enabled property to false.

var blocks = GameObject.FindGameObjectsWithTag ("Block");

for (var block in blocks)
{
    var blockfall : BlockFall;
    blockfall = block.GetComponent(BlockFall);
    blockfall.enabled = false;
}