# How to make a wait statement in p5js (if its even possible)

**URL:** <https://discourse.processing.org/t/how-to-make-a-wait-statement-in-p5js-if-its-even-possible/34134>\
**Category:** p5.js\
**Created:** [December 15, 2021, 1:24pm UTC](https://discourse.processing.org/t/how-to-make-a-wait-statement-in-p5js-if-its-even-possible/34134 "2021-12-15T13:24:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![parichko](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@parichko](https://discourse.processing.org/u/parichko)\
**Post date:** [December 15, 2021, 1:24pm UTC](https://discourse.processing.org/t/how-to-make-a-wait-statement-in-p5js-if-its-even-possible/34134/1 "2021-12-15T13:24:47Z")

</div>

I am working on a code that will be a lot easier if I knew how to make a wait statement. If you know please leave a quick reply.

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [December 16, 2021, 12:38am UTC](https://discourse.processing.org/t/how-to-make-a-wait-statement-in-p5js-if-its-even-possible/34134/2 "2021-12-16T00:38:43Z")

</div>

One thing you do not want to do in p5.js is block the draw function for an extended period of time. However if you want to discontinue all drawing activity for a period of time and then resume from the beginning of your draw function, this is doable:

```javascript
function draw() {
  background(random(100, 200));
  if (shouldPause) {
    // stop calling draw every frame
    noLoop();
    // Resume calling draw every frame after 5 seconds
    setTimeout(() => loop(), 5000);
    return;
  }
}

```

This may or may not work for your scenario, we would need to know more about how your sketch works and why you want to “wait” in order to give you a more suitable recommendation.
