"get all actors with tag" means random?

Do you have any idea what is wrong with my BP (i add a screenshot below)?
As you can see I create a function to change the material of tagged -static mesh actors-.
It’s actually working, but he result is not expeted. Every StaticmeshActor get one of the 3 materials, but set randomly (an actor B get a material 1; an actor A get material 2 etc… and when i hit B get 3 and A get 1 etc…) .Instead of getting the material 1 for actors A and B, then only material 2 for A and B etc…
And do you know if there is a way to connect my “for each loop” directly to the target of the “set material” instead of use a “cast to staticmeshactor”? (I’m wondering if this “cast” give this bad result)

Thanks

Get all actors with tag does not get them in a certain order like you expect. One time actor A will be first, the other time actor B. It does not know they should be in a specific order. Im not sure what your expected result is… if you want all actors to have the same materials you need a forloop, not do n loop. And the indexes you are setting would probably be 0,1,2 and not 0,0,3.

Hi IGorilla, thanks a lot for the reply. The 0,0,3 is a mistake of me, searching if there was consequence changing thoses values. The only way to get an action is to set all on 0 (0,0,0)*. I send an other screenshot to corrige it.

I don’t want to consider order with my actors. I just want them to change material all together in the same time. Something really basic. The only order i want is material 1 when i hit (of all actors); than material 2 etc…

You said to use forloop instead of n loop. But it’s seems that i call all the 3 materials in once (so nothing happend). To simplify i replace those integer system by a simple multigate (as you can see on the screeshot).
Do you think the problem could come from the “cast” part ? And do you know an other method to connect an actor to a target which accept only the “primitive component” ?

Thanks

Not a problem of casting. With an other method found on internet, same weird redult.
Do you thing i have to add something on the array index’s node of “for each loop” ?

This is a silly solution but it’s working*
Thanks to the community