Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I want to make a Clone inside of a forever loop, only one, but hundreds come out
- b3rnardo_o
-
Scratcher
26 posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
I want to make a Clone inside of a forever loop, only one, but hundreds come out. This is my script:
This suddenly makes hundreds of clones the entire time and scratch even crashed once. what can i do to only make one clone?
when green flag clicked
forever
if < (y position :: variables) = [320]> then
create clone of [myself v]
This suddenly makes hundreds of clones the entire time and scratch even crashed once. what can i do to only make one clone?
Last edited by b3rnardo_o (March 5, 2023 19:41:45)
- medians
-
Scratcher
1000+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
Why are you using a variable for the y position? If you're trying to get the y position of another sprite, you can do this:

Are you trying to make less than or equal to, or greater than or equal to?
And it's because of the forever loop, wait until the position is not 320.

Are you trying to make less than or equal to, or greater than or equal to?
And it's because of the forever loop, wait until the position is not 320.
- b3rnardo_o
-
Scratcher
26 posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
I want to make a Clone inside of a forever loop, only one, but hundreds come out. This is my script:when green flag clicked
forever
if <<(y position :: variables) = [320]> or < (y position :: variables) = [320]>> then
create clone of [myself v]
This suddenly makes hundreds of clones the entire time and scratch even crashed once. what can i do to only make one clone?
- Catscratcher07
-
Scratcher
1000+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
after creating the clone,
stop [this script v]
- medians
-
Scratcher
1000+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
(why exactly was the op quoted?)Yes I know, but you don't need to use a variable for the y position of another sprite if that's what you're trying to do because there is a sensing block that reports an attribute of the selected sprite (including y pos).
And do you mean this?

Or this?

- b3rnardo_o
-
Scratcher
26 posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
I edited it back. srry
- medians
-
Scratcher
1000+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
after creating the clone,They might want it to keep going.stop [this script v]
In that case:

(replace the code inside the if statement with this)
However, I'm not sure how the y position is changing here, so it might be creating infinite clones if it just keeps going back to 320.
Last edited by medians (March 5, 2023 19:43:15)
- smisamul6
-
Scratcher
100+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
after creating the clone,stop [this script v]
- an_unknown_user123
-
Scratcher
30 posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
You can stop this script after making a clone.
Should look like this:
Should look like this:
when green flag clicked
forever
if <(y position :: variables) = [320]> then
create clone of [ myself v]
stop [this script v]
end
end
Last edited by an_unknown_user123 (Sept. 23, 2023 16:35:16)
- medians
-
Scratcher
1000+ posts
I want to make a Clone inside of a forever loop, only one, but hundreds come out
Well, if they wanted to stop the script right after, they could just use a wait until block:after creating the clone,stop [this script v]

However, if they wanted it to continue, they would need to just use a wait until block like done in the other way.
- Discussion Forums
- » Help with Scripts
-
» I want to make a Clone inside of a forever loop, only one, but hundreds come out