var collected_coins = 0; // doesn't have any coins yet
action coin() // attach this action
{
while(vec_dist(my.x,player.x) > 50)//while player is far than 50 quants
{
my.pan += 5 * time_step; // turn my pan
wait(1);
}
//if player is closer than 50 quants
collected_coins += 1; // add one coin then
// can play some sound here
}