Help understand the issue with random object creation

Hello folks,

First of all, I honestly am not that much of a developer, but rather a game designer, and surely newbie in GDevelop as well, so…
Well, whatever the excuse.

Here is part of my project:

In these lines I desperately trying to achieve some sort of a randomly generated placement, getting one desired and throwing those don’t fit. In some hacky, dirty way, yeah, but… it works. Kind of. Like, it can succeed 10-15 times in a row, and then suddenly failed one or two times, spawning object that lies not in the range, or stuck in other. I guess there are some hidden limitations in this all, but it works VERY fast in either case

And so, what’s wrong? Any ideas?

I think if you use trigger once condition and a timer you can get the desired effect. At the moment i think thats why everything is happening so fast.

Well, it’s supposed to be fast… That’s why I decided not to use any interruption. Setting a timer… I didn’t notice any performance spikes or freezes, or whatever telling the engine was overwhelmed with spawning and calculating dozens of objects. It takes literally second or two…

Edit:

Nevertheless, I ended up setting a tiny timer wrapped around. And it seemingly solved the issue! Still, I’m not sure I’m catching what was hide under the hood…

Edit 2:

Well, further extensive testings proved it was not a solution. So…

Edit 3:

It seems I found a workaround here, by spawning objects in a special layer and then putting them back into the main, while adding some checks into the logic as well