The second script will trigger the query and we'll use the value of the variable to pass the index of the repeatable. However, this one needs a 'Debounce' of 100ms to wait for the variable to update, we can probably use less but 100ms won't be noticeable and it's a nice cushion:
Note: We don't need to use await because of the debounce so feel free to remove it on your end. I tried doing them on the same script using await but the query seems to be using the cached value of the variable. The value of index was always one step behind.