Check if variable is stored within an Array

Background:

I'm devising a game where the player is protecting a village.
The village is comprised of 9 families.
Each family has a cohesion stat - tracked by a variable for each family.
An event decides that an terror will take place, it assigns 1 of the 9 families at random.
The player undertakes a quest to help the family.

If they succeed the family cohesion is unchanged.
If the player fails a family member dies and the cohesion score is lowered.

Goal:
What I'm trying to do is make this system as scalable as I can, without relying on too many switches.
I want to see if I can use arrays to track each family's status and that's where I'm running into problems.

variable ID 22 family_assign represents the family being selected by the event, it does so by random number generation (1-9)

It then checks to make sure they're eligible, this is where the arrays come in.

I have a variable: family_KO_array which I store an empty array at game start using a common event and Control Variables command. See the screenshot below:

1721189680922.png

The above example didn't produce an error

When a family falls below the cohesion threshold - currently 50 - the common event pushes their number (1 to 9) to the array.
This generates my second error, same as the first from what I can see in the debug.

1721189720447.png

Error1:
1721191455030.png

Should the above just be a script on its own instead of using control variables?

The event randomly assigns a family via a generated number between 1-9 storing it in "family_assign" (variableID 22)

In the screenshot below I'm trying to check if the value of family_assign is stored in family_KO_array (varioable28)
This of course generates an error as well.
1721190064085.png

Error2:

1721191278943.png


I've tried .includes and .some with the same result.

Any guidance in this endeavor is appreciated.
2nd screenshot:

When you alter an array, don't use Variable OP but a script:

Code:
$gameVariables.value(1).push(2)
2nd screenshot:

When you alter an array, don't use Variable OP but a script:

Code:
$gameVariables.value(1).push(2)

Thank you,

Its all fallen into place now.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-variable-is-stored-within-an-array.170376/