> For the complete documentation index, see [llms.txt](https://docs.scratch-for-discord.com/use/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scratch-for-discord.com/use/toolbox/functions/loops.md).

# Loops

## Repeat forever

To make your script run forever.

<figure><img src="https://2077548579-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3xg7dEw96L10OHOz0yDz%2Fuploads%2FKc724OwwhIWB8LQimOkH%2Fscreenshot%20(99).png?alt=media&amp;token=588731d7-6adf-4946-adab-22611a75a8ae" alt=""><figcaption><p>Example of using repeat forever</p></figcaption></figure>

## Repeat while & until

While condition will run when it´s true, until will stop when it´s true

<figure><img src="https://2077548579-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3xg7dEw96L10OHOz0yDz%2Fuploads%2FyQUHYSNTEha1YWtOxgN9%2Fscreenshot%20(100).png?alt=media&amp;token=be01eb3c-ecf5-40f4-8377-6fa7ae8d3a40" alt=""><figcaption><p>Example of using While and Until loop (these are the same)</p></figcaption></figure>

## Count with I from X to Y by Z

<figure><img src="https://2077548579-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3xg7dEw96L10OHOz0yDz%2Fuploads%2FpTNM6yKHR8haDjdhdaQe%2Fscreenshot%20-%202022-10-24T130212.531.png?alt=media&amp;token=9fc24d36-ac0f-451b-bb28-5732c287c6d2" alt=""><figcaption><p>Example of using count with I loop</p></figcaption></figure>

{% code title="Output" %}

```javascript
a
b
c
```

{% endcode %}

## For each item in list

Good to make a loop for example. for every member check if someone has a role

<figure><img src="https://2077548579-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3xg7dEw96L10OHOz0yDz%2Fuploads%2FroOMmttcpKdPhGvnPBnl%2Fscreenshot%20-%202022-10-24T130534.262.png?alt=media&amp;token=e2dcc6e5-cd27-448a-8bc2-1d89b3b9c696" alt=""><figcaption><p>Example of using for each item loop</p></figcaption></figure>

Output will be the same as Count with I loop

## Break out of loop

Basically stops the loop script

<figure><img src="https://2077548579-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3xg7dEw96L10OHOz0yDz%2Fuploads%2FvYi1NNhjf5ATZislN9WE%2Fscreenshot%20-%202022-10-24T125732.463.png?alt=media&amp;token=e4928ae1-1048-4279-9195-5b0dd2a87ac4" alt=""><figcaption><p>Example of using break out of loop</p></figcaption></figure>
