Just put wait(1) in the first while or use a for loop, because he jump out...with wait(1) the function is waiting for second while. I have had the same problem with count alpha from Panel.