Forever loop stopping after running once

in a project that i made, there is a part where a sprite (called moving platform) constantly tells all of its clones to run some code. it does this making use of a forever loop:
Block Flipper script pic
Block Flipper script pic-2
Block Flipper script pic-3
however: when the top script is run after being re-triggered, (by re-sending the "start" message) the block in the forever loop only runs once. this might be a bug, or something might be wrong with my code.

please help me figure out what's wrong and fix it.
Thank you!

project link

Block Flipper

I don't think this will fix it, but your running a forever loop inside a forever loop :slight_smile:

If you broadcast start while the when I receive start script is running, it won't run again, because the script is already running. You'd need to stop the script before running it again, either with a repeat until instead of a forever loop, or by using the stop block.

And as @joecooldoo said, you are running a forever loop inside a forever loop. You might want to either remove the forever loop inside the custom block, or from the script running the custom block (I would remove it from the custom block, so I can run other code after running it, but also being able to run it again).

I added that just to test if it would work to fix it. I’ll
Remove it.

Ok I’ll try that, thanks.

it turns out there was a script that was supposed to fix the issue you mentioned, but it was stopping the script too late -_-

off topic but

Did you know: a clone can be permanent, so the good way to check if i'm a clone is to check at me parent... if my parent is null, i'm not a clone...

untitled script pic (2)

image

I know about that, but when I'm programming i don't consider permanent clones to be clones.
and I don't usually use them anyway.
(:

that wont work either if the clone sets the parent to something

this kind of works:
untitled script pic
but if a non-cloned sprite sets its parent to something, this block reports true.
I couldn't think of any better ways to do this, so I think which one you use just depends on what kind of clones you're using.

if you set myParent of a sprite to another sprite, this sprite is now a permanent clone...

if you want to try:
create 2 sprites (sprite1 & sprite 2)

in scripting area into sprite 1: drop any blocks

goto scripting are into sprite 2 (empty):
-set the parent to sprite 1
-drop the block inherit(script) block and run it...
-all the blocks from sprite 1 are imported into sprite 2

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