Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
Hello. So, recently I was messing around with my new physics custom brick, which was a move script that allowed for friction to slow down an object moving. But, when I made a script to let me throw around the object using my cursor and the “space” key, the forever loop that should have let me repeatedly throw it around stopped after I pressed the space key, which started its own “until space key not pressed” loop. But, when that loop was over, the forever loop stopped working and stopped repeating after that loop. There was a custom block after that loop, so it could have been that. I don't really know
. Here is the image showing all of the components of the project. (It had to be in a link because I'm not experienced enough to be a “scratcher”).
https://postimg.cc/mhr13vsY

https://postimg.cc/mhr13vsY
Last edited by Vaieve (Feb. 1, 2023 00:25:55)
- Spentine
-
1000+ posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
I don't think that would work, especially since you have two scripts that will add velocity.
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
I don't remember commenting “a”, but I'll remove the comment if it is there, sorry for your inconvenience. I don't think that would work, especially since you have two scripts that will add velocity.
Also, the other script ended up being pretty irrelevant, but, when I removed that script, the problem still persisted.
Edit: I never commented “a” on your profile.
Last edited by Vaieve (Feb. 1, 2023 00:35:54)
- forumhelperman
-
86 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
Hello, First off, please use trusted host sites - like cubeupload. To make sure the website isnt malicious. (this one is fine though).
First off - try compressing all the loops into 1. Multiple forever loops are pretty finicky with timings - especially in physics engines when you want things to run in a certain order.
Also, it might be that the “space” key isn't pressed, so scratch cuts out all the code thats not being used. Other than that, I would have no clue.
First off - try compressing all the loops into 1. Multiple forever loops are pretty finicky with timings - especially in physics engines when you want things to run in a certain order.
Also, it might be that the “space” key isn't pressed, so scratch cuts out all the code thats not being used. Other than that, I would have no clue.
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
I will try to do that, hopefully it will work. thank you for the advice!
- Spentine
-
1000+ posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
So… there is something called a signature. Under every post I send, it's going to be there. I set it to “pls dont comment ”a“ on my profile” so that people will look at my profile. You can edit your signature here.I don't remember commenting “a”, but I'll remove the comment if it is there, sorry for your inconvenience. I don't think that would work, especially since you have two scripts that will add velocity.
Also, the other script ended up being pretty irrelevant, but, when I removed that script, the problem still persisted.
Edit: I never commented “a” on your profile.
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
Thank you for telling me that, I will be sure to use it.
Last edited by Vaieve (Feb. 1, 2023 00:47:01)
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
I managed to remove the other forever loop without the game breaking, and inserted the code after the “go to” brick in the forever script, and… It got worse. When I moved the ball with my cursor, not only did it freak out scratch and made the site lag out like crazy, the problem still persisted! This might be just a unfixable bug… Hello, First off, please use trusted host sites - like cubeupload. To make sure the website isnt malicious. (this one is fine though).
First off - try compressing all the loops into 1. Multiple forever loops are pretty finicky with timings - especially in physics engines when you want things to run in a certain order.
Also, it might be that the “space” key isn't pressed, so scratch cuts out all the code thats not being used. Other than that, I would have no clue.
- Vaieve
-
12 posts
Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.
I managed to fix the problem. I split the script into 2 scripts: one for the loop and key detection, and one for the custom block. The custom block had a “repeat until” brick, which was stalling the script, so I broadcasted a message to the custom block instead of fitting it into the same script, and now the problem is fixed 

- Discussion Forums
- » Help with Scripts
-
» Forever loop ending after running through another repeater or custom block once, despite there being no end bricks.