# What's wrong with this while loop??

**URL:** <https://forums.unrealengine.com/t/whats-wrong-with-this-while-loop/420313>\
**Category:** Community & Industry Discussion\
**Tags:** delay, while-loop, unreal-engine, crash, runtime, question\
**Created:** [March 20, 2018, 2:38am UTC](https://forums.unrealengine.com/t/whats-wrong-with-this-while-loop/420313 "2018-03-20T02:38:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_9014a006](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9014a006](https://forums.unrealengine.com/u/anonymous_user_9014a006)\
**Post date:** [March 20, 2018, 2:38am UTC](https://forums.unrealengine.com/t/whats-wrong-with-this-while-loop/420313/1 "2018-03-20T02:38:04Z")

</div>

Nvm check your array sizes and conditionals everyone

---

<div class="post-metadata">

**Author:** ![vivalabugz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vivalabugz](https://forums.unrealengine.com/u/vivalabugz)\
**Post date:** [March 20, 2018, 3:39am UTC](https://forums.unrealengine.com/t/whats-wrong-with-this-while-loop/420313/2 "2018-03-20T03:39:46Z")

</div>

Hey meimeicheng,

It seems like you’re “Num Doors Open” variable is never going to be equal to 3 and your array will eventually be empty. This is probably whats causing the crash. You need to be able to exit the WhileLoop when running it; make your “Num Doors Open” = 3 after the WhileLoop. I’m assuming you probably only want to check once on the overlap, you probably want to do a Branch instead if a WhileLoop.

Branch- if (“Num Doors Open”+1) != 3 is True, execute your code after the WhileLoop(obviously without the WhileLoop)

---

<div class="post-metadata">

**Author:** ![vivalabugz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@vivalabugz](https://forums.unrealengine.com/u/vivalabugz)\
**Post date:** [March 20, 2018, 4:42am UTC](https://forums.unrealengine.com/t/whats-wrong-with-this-while-loop/420313/3 "2018-03-20T04:42:08Z")

</div>

yeah, thats essentially what I was stating
