# Infinite loop error on standart Blueprint's macro

**URL:** <https://forums.unrealengine.com/t/infinite-loop-error-on-standart-blueprints-macro/435376>\
**Category:** Blueprint\
**Tags:** macro, infinite-loop, unreal-engine, Blueprint, question\
**Created:** [October 10, 2018, 9:05am UTC](https://forums.unrealengine.com/t/infinite-loop-error-on-standart-blueprints-macro/435376 "2018-10-10T09:05:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenryVIII](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HenryVIII](https://forums.unrealengine.com/u/HenryVIII)\
**Post date:** [October 10, 2018, 9:05am UTC](https://forums.unrealengine.com/t/infinite-loop-error-on-standart-blueprints-macro/435376/1 "2018-10-10T09:05:11Z")

</div>

![256126-зауваження.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/e/96e0686aeecc3a16616a7789841b093246ee4f88.png)

Hi, this is my AiController Blueprint and after running it I every time get infinite loop error on Do Once nod. I tried to replace Do Once with a branch but it detected infinite loop on set variable node. Sometimes it detects infinite loop on ForEachLoop macro.

I can’t understand what is happening

---

<div class="post-metadata">

**Author:** ![HarryHighDef](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HarryHighDef](https://forums.unrealengine.com/u/HarryHighDef)\
**Post date:** [October 10, 2018, 9:41am UTC](https://forums.unrealengine.com/t/infinite-loop-error-on-standart-blueprints-macro/435376/2 "2018-10-10T09:41:32Z")

</div>

You should connect your shuffle node from the complete pin on your loop. Also consider using a random int within your array length rather than shuffling. Shuffling is very intensive and can lag out even with small arrays.

---

<div class="post-metadata">

**Author:** ![HenryVIII](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HenryVIII](https://forums.unrealengine.com/u/HenryVIII)\
**Post date:** [October 10, 2018, 1:43pm UTC](https://forums.unrealengine.com/t/infinite-loop-error-on-standart-blueprints-macro/435376/3 "2018-10-10T13:43:19Z")

</div>

Thanks for optimization advice but I have found that custom event causing this error, I am still don’t understand where is an Infinite loop here but my workaround looks like this

 ![256139-зауваження.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/a/bfad07e31b54c1efde22865fbb2ec324d19a4c52.png)

This kinda strange because this blueprint was an example from teaching book, maybe for an earlier engine version.
