Occassional Crashes on Spell Cascading

I have a Life creature casting Guardian Force on Provoke as well as manually. This causes all of my other creatures to defend.

I have the Wallflower trait in my team, so when a creature defends, they cast a spell. This quickly turns into dozens of spells being cast.

It occasionally crashes but I have not been able to figure out why.

Attaching save so you can see my team setup.


############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_battlecontroller:

Push :: Execution Error - Variable Index [0,2] out of range [1,2] - -7.targets(100002,2)
at gml_Script_bc_CreatureCast
############################################################################################

stack frame is
gml_Script_bc_CreatureCast (line 0)
gml_Script_bc_CreatureCastSpellGem
gml_Script_bc_OnDefend
gml_Script_bc_CreatureDefend
gml_Script_bc_CreatureCast
gml_Script_bc_CreatureCastSpellGem
gml_Script_bc_SpellsOnHit
gml_Script_bc_OnProvoke
gml_Script_bc_CreatureProvoke
gml_Script_bc_Turn
gml_Object_obj_battlecontroller_Step_0


slot4.sav (512 KB)