I made that press-as-fast-as-you-can-to-gain-heart NPC some time ago,but it works
it may help you (the variables have german names)
NPC Code:
if (keydown(5)&&!this.irgendwas2=1&&playerx<64&&playe rx>58&&playery<38&&playery>33) {
if (this.irgendwas>-1&&this.irgendwas<30) {this.irgendwas+=7;}
if (this.irgendwas>30&&this.irgendwas<60) {this.irgendwas+=6;}
if (this.irgendwas>60&&this.irgendwas<90) {this.irgendwas+=5;}
if (this.irgendwas>90&&this.irgendwas<120) {this.irgendwas+=4;}
if (this.irgendwas>120&&this.irgendwas<150) {this.irgendwas+=3;}
this.irgendwas2=1;}
if (playerenters) {timeout=0.05;}
if (timeout) {if (!keydown(5)) {this.irgendwas2=0;}
if (!this.irgendwas<1) {this.irgendwas--;}
timeout=0.05;
y=34-(this.irgendwas/10);
message #v(this.irgendwas)
}
if (this.irgendwas>150) {set gewonnen;}