Loops are all executed in one tick, even if there are wait actions inside. So in your case you are creating an infinite loop and a huge number of wait threads. The rest of the code after "wait" never gets executed (because it can only happen on the next tick). That's why your project freezes.
Also, when using "While" and there is even a slight possibility of an infinite loop, I recommend adding another condition - "Loopindex<1000". This will ensure that the loop will terminate after 1000 cycles.