If you search your coins and go to the address, you get the keys around 30 addresses below, right? So, a nearby search for say 500 with a distance of 30 will return every value within an offset of 30 from the coins value that is equal to 500.
This means that if I find gold value and nearby searches the keys value (which the script prompts for) with a distance of say 40, every value that has the prompted value will come up. If you have, say, 42 keys, and you nearby search 42 with distance of 40, and only with the option "After" checked and not before (shown in the attached pictures), I should get my keys value. And since I am only searching 40 addresses, most likely the only one that equals 42 is my keys value.
To make use of this, click "record script" and record yourself doing this nearby search. Then open up that script as a text file and copy the code and add it into your script.
Coins and score are dword ...?