I have provided you a test map, the trigger is bugged at first but has been fixed by Jay the Editor (about looping integer, use another integer variable)
INSTRUCTIONS;
1. Select a unit to assign index value to that unit
2. Re-select the unit (click/drag-select/etc) to view what index value does the unit currently holds
The idea is to loop through all index size and check whether (Triggering unit) or any other event-response (in your case, it should (Target unit of ability being cast)) is equal to Unit[LoopingValue]
If the LoopingValue reaches certain value and that unit is equal to (Target unit of ability being cast), the value has reached.
For example, you have target a unit that has index of 8, which means Target[8]
The next time you cast the spell, it would loop through all index size, which in this case currently max size is 8
So from 1 to 8.
(Target unit of ability being cast) Equal to Target[1] - NO
(Target unit of ability being cast) Equal to Target[2] - NO
---
---
---
(Target unit of ability being cast) Equal to Target[8] - YES
That means, that unit holds index value of 8.