# Array isnt updating, for each loop only running once.

**URL:** <https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175>\
**Category:** Blueprint\
**Tags:** UE-5, unreal-engine, UE5, question, UE503\
**Created:** [January 6, 2025, 7:39pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175 "2025-01-06T19:39:26Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 6, 2025, 7:39pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/1 "2025-01-06T19:39:26Z")

</div>

Hey there,

Im having an issue with for each loops.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/0/c00826de192edeee58e6c2c339c0bcb52cd5d97b.png)

You can see here some pretty simple nodes.

heres whats in the array.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/c/a7cd5c8a7172d5997bcef29a86898a5d9157a967.png)

Ok Easy. So this should show 5 prints with each number.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/9/f/19f91d1f8aab73e647d14693aba4fa9fab3d353c.png)h

Ah…So it went through…once? Ok so what happens if I change the list.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/d/37dc1f1bcb1c2412d9c6b7135acb31387c1ecf19.png)

Lets test.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/2/a1261e227632b7d516411d0d3f51c7d8d59a9b04.png)

Right so it didnt even update it to the new array I manually changed?

Anyone have any idea whats going on?

Thanks for reading.

---

<div class="post-metadata">

**Author:** ![56legion](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/56legion/32/1194529_2.png) [@56legion](https://forums.unrealengine.com/u/56legion)\
**Post date:** [January 7, 2025, 2:38am UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/2 "2025-01-07T02:38:50Z")

</div>

So, your blueprint is wrong. Take a look at my result. I’m guessing you want to achieve something similar to this, right?

 ![{2BA2E5C5-0C7E-446F-9C3E-02DCC287B489}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/a/29a9954a4ddbc8d2bd4e2b45b536c3f063894ed2.jpeg)

Your setup logic should be like this:  
Your parent class widget should inherit a vertical or horizontal box, and then you can add the child class, as in the screenshot below.

 ![{1917D52A-9D5B-4BA8-94F2-34D0D57AF78F}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/e/dee69625460fe114923a017995c7c54d03677d30.png)

Even if you implement the scroll box, it should be like this:

 ![{15054F26-70B7-4DEF-B37A-9DCB0F66CD76}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/3/5c3bd8c0da4212c92a2dcb01b6800cce495d1f37.jpeg)

To put it simple, I’m guessing your widget component is the problem. This is the parent widget class component hierarchy. Hope it helps.

 ![{F329C75E-3B24-4FE4-9CA9-3090FC3F03B5}](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/e/3cea6fa2991fa6bf6c58bb12e18b8a8f4f799770.png)

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:03pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/3 "2025-01-07T12:03:49Z")

</div>

I think Im confused. Ive used this way several other times and it works normally but this time its acting up.

lets say I swap out the scrollbox entirely. Just adding to a vertical box.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/b/bfb6cb6b45ed4ba9bfb61bad58803014da3823e8.png)  
This is the hierarchy.  
Inside it is this  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/6/fd6400e59fa7a89a80b4136c090bb754eb792d4e.png)  
and this is the default values  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/4/664f2526f95e83f12476b80ed4660e764ac3cf73.png)

So it should should produce 5 widgets, with the list names.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/e/4de5c37f3f47580d07fa5bea9e8f05f612fe9600.png)  
But it produces this.

So it Could be the title card widget itself. which just contains this

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/c/33c29e3737757d0caf2f5c85479a459f58b541ac.png)

Now this hierachy is just this  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/0/fa0a9ba630d4628bd373155ff089daeeac6d899f.png)

Essentially pulling from a global button I made So I could adjust it and every button would change here.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/d/72def3338ae639bb62b1e7f2273e261f27018ae3.png)v

This system has worked everywhere else. But for some reason right now in this specific blueprint. It just doesnt want to work. It clogs itself up.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:08pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/4 "2025-01-07T12:08:51Z")

</div>

> Ok Easy. So this should show 5 prints with each number.

Print the `Length` of this array:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/7/497130f09c56b6eed2ffc422f0c312ab85e30e78.png)

What do you get? if you get nonsense, select the `For Each Loop` node and hit F9 to add a breakpont. Run the project, do you hit the breakpoint?

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:14pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/5 "2025-01-07T12:14:38Z")

</div>

It’s made inside the widget, It’s nothing special. Just inside the widget, created the variable, made it an array and filled it.

It doesn’t get pulled from anywhere else. It’s just a manually made variable in the widget.

In fact wierdly, what If I just totally removed everything except the print

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/8/4a88e6faa38feb63cef7c1a10d963e2fe4850f50.png)

Still shows this xD.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/8/9/8898a1a36139d0081857f12b9fde27e313c86f73.png)

When the details is this

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/f/e4fa46b85664c9b24ae6ec41e0bd0d66d969ab30.png)

Something funnys going on.

This widget is part of a broader widget which uses a widget switcher but Ive used this same system before and its always been fine.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:15pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/6 "2025-01-07T12:15:20Z")

</div>

> [@Skyboy](#):
>
> Something funnys going on.

My bet is that you’re looking at the wrong widget. Check my post above.

> Ive used this same system before and its always been fine.

Precisely, this works - we’re looking for an issue that is elsewhere.

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:23pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/7 "2025-01-07T12:23:15Z")

</div>

Ah sorry didnt see that, the length is counting something

This is the results of this noodle maze.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/a/6aaf394eaf4716232c32e84dd0bbe5a914d6103f.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/5/6b56ccf164c3bcf2401c8822bba9a3245661f2d4.png)

Which is defo strange now. 0 to 4 overall 5. the list is wrong and gets lost after number 1.

Wierder still the details list looks like this lol.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/9/3/b9344a58bb681c1aa92d3bcf89074bed0056dfa2.png)

I did a breakpoint on the for each loop, Something to note, I opened this up yestarday and the “length” node was errored, I refreshed it (Just right click refresh) The error went away and Ive had issues since.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/3/1e308556b7f4f4e360982804400a06acb7c2e639.png)

Breakpoint hit.

and inside the loop

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/2/2f2a53f884c2772c73bc9bd26ace92ecc367dc73.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:29pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/8 "2025-01-07T12:29:21Z")

</div>

> [@Everynone](#):
>
> ~~My bet is that you’re looking at the wrong widget.~~

> Breakpoint hit.

Apparently we **are** looking at the correct widget, my bad.

It’s printing empty array entries:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/d/b/2db3ec97483736301e54d1ba8ca0b2800a72f6a4.png)

* * *

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/3/9a38017bc6b62d004ed54d0ca4a167abc09663d2.png)

Is this ☝ an `Instance Editable` variable that you `Expose on Spawn`?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/6/ac63b43aa0966ea3aa12c14887942421ba388bd7.png)

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:33pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/9 "2025-01-07T12:33:21Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/9/f/99f18ec8a4a3b8b92dfa864a152e37a2ddb4e79a.png)

At the moment, like my other ones It’s neither instance editable nor exposed on spawn. If I turn them both on. I get the same result.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/5/9a515484bfb43a14d3f20c70a2bd45886b002028.png)

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/f/05f3b4bd9f5bd5e880e26f0f51775747aaea3106.png)

Missing list information, but the gap does exist.

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:37pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/10 "2025-01-07T12:37:10Z")

</div>

Ok Not sure if this matters at all but I have a widget switcher created when the options are made and the same thing happens. This whole system might be problematic

I attached this to my main hub

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/b/9bb45bde070c47cefdb8091950a14dc0509502e3.png)

Same problem except it looks like this

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/7/6571ab6c4784119eac4695ca835b9ffd3f30b3b1.png)

wierd huh

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:38pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/11 "2025-01-07T12:38:48Z")

</div>

> [@Skyboy](#):
>
> If I turn them both on. I get the same result.

I was merely hoping we were piping in data dynamically and the array was overwritten.

> Ok Not sure if this matters at all but I have a widget switcher created when the options are made and the same thing happens. This whole system might be problematic

That was my next thought - what if you manually create just this widget as a stand alone on Begin Play, without the switcher? Does it behave normally?

Essentially, the array has 5 entries but they never get updated. That’s the gist, right?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:41pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/12 "2025-01-07T12:41:48Z")

</div>

Also, which switcher index is this widget at? And what is the default switcher index? I have a weird feeling it has something to do with initialisation.

* * *

Try this:

- remove the widget from the switcher
- modify the array, save, compile
- add it back to the switcher

Thinking about it, I’ve seen widgets **retain**  **stale** data.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:47pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/13 "2025-01-07T12:47:19Z")

</div>

And here’s another thing to try:

- in the widget, set the array as `Instance Editable`:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/1/e4120e0d294ba66cc50b613e4d0496564025f77f.png)

- in the `Switcher` owner, select the widget with the abovementioned array and populate it there:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/9/fa984b4df7ed1c6c015f6914c4a04117d63b8f1a.png)

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 12:51pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/14 "2025-01-07T12:51:20Z")

</div>

> [@Everynone](#):
>
> Essentially, the array has 5 entries but they never get updated. That’s the gist, right?

Yeah, this is not a dynamic system, it never changes. It doesn’t need to pull from anything. So it just has to add the text to the box and put it in the vert box. (Ill then be attaching some non-dynamic but animated stuff around it.)

> [@Everynone](#):
>
> Try this:
> 
> - remove the widget from the switcher
> - modify the array, save, compile
> - add it back to the switcher
> 
> Thinking about it, I’ve seen widgets **retain**  **stale** data.

Ok so I removed it from the switcher, changed the data, reput it into the switcher and then tried again and lo and behold.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/e/3/be3d7df5fd64483026b806215d6db9be3b26ed34.png)

Counting correctly

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/d/fbd832300769dbc01ecab9f6cb483c3c6e88ca8d.png)

Shows up correctly.

What black magic is this xD.

are switchers just to be avoided? why would a switcher hold onto stale data?

So it seems it no longer gets its infomation from the widget, but from the switcher widget overridding the initial widget.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 7, 2025, 12:54pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/15 "2025-01-07T12:54:16Z")

</div>

> [@Skyboy](#):
>
> are switchers just to be avoided? why would a switcher hold onto stale data?

It can get nasty like that and a nuisance to update. Try the thing from the post above:

> in the widget, set the array as `Instance Editable`:

it should work fine. 🤞

---

<div class="post-metadata">

**Author:** ![Skyboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skyboy](https://forums.unrealengine.com/u/Skyboy)\
**Post date:** [January 7, 2025, 1:04pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/16 "2025-01-07T13:04:49Z")

</div>

My brain is foggy today, Yeah, that above is exactly it. It no longer uses the updates from the initial widget, as soon as it’s under the widget switcher widget it sources all its content from there now I guess.

Absolutely wild. This actually might have cleared up some problems I was having like 6 months ago as well that I solved but didn’t really understand what or how when I used another switcher for the main game.

Iv now zerod out my options widget list.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/9/829013c04df8c0d1adc3b8e0b0ccdf899b8ff6c3.png)

And now making the adjustments from the “master hub” widget switcher with the list widget inside it.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/4/614d1e54edfb4b798c2391c03b5d1d5c89c2304d.png)

Thank you for helping me plough through this, I’ve been 2 days deep and absolutely baffled. Interesting system that I’m defo going to take advantage of.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 6, 2025, 1:05pm UTC](https://forums.unrealengine.com/t/array-isnt-updating-for-each-loop-only-running-once/2263175/17 "2025-02-06T13:05:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
