Repeat for each object + pick random object [Solved]

Hello! Greetings to All!

I’m trying to make fight mode in idle game. I have faced problem with Repeat for each instance. I want to repeat certain actions that has conditiones Pick a random object, one by one. I want to pick 2 different objects in each subevent - one is player and the other one is enemy.

I would like have events happen in the order it is written so:

  1. GlobalHeroes belonged to Player is picked and the value of scene variable is updated with the objects attack
  2. GlobalHeroes belonged to Enemy is picked and players attack value substracts the currentHP (100hp on start) of enemy

What is happening?

First attack has value of 0, while the value should be 26, so i think that something inverts the order of events. The other thing is that enemy isn’t chosen more than once (it supposed to be)

If there is anything unclear I’ll try to explain it, just let me know

Regards,
Ernest

After many tries I have forgiven. In the place of objects (that are just variable containers) I will use Structure Variables. It’s way easier to change Variables than picking the object :smiley:

https://wiki.gdevelop.io/gdevelop5/all-features/variables/#accessing-child-variables-in-structures-or-arrays

Link above has helped me

Regards