Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to create only one clone?
- tobkelsus
-
6 posts
How to create only one clone?
I feel as though there may be some very obvious answer that I just can't figure out, but how do I continuously create only one clone? Example:
I have a script that says “When x key is pressed, create clone of myself” The first time I do it, it's fine. I go from 1 to 2 objects. But when I do it again, it goes from 2 to 4. Is there any way to make it so it only makes one copy each time? Please help!
I have a script that says “When x key is pressed, create clone of myself” The first time I do it, it's fine. I go from 1 to 2 objects. But when I do it again, it goes from 2 to 4. Is there any way to make it so it only makes one copy each time? Please help!
- jokebookservice1
-
1000+ posts
How to create only one clone?
You could make a script like this:
This will have some differences to the hat block, though it should be fine
- ECLIPSE-STUDIOS
-
100+ posts
How to create only one clone?
Hi,
Create a variable and give it a name like “Cloned?” and select “For This Sprite Only”. Set it to 0 at the start and whenever the clones are deleted/reset.
Then, in the “When x key is pressed” script, put if cloned? = 0, create a clone of myself and set cloned? to 1. Don't put an else, but MAKE SURE IT CLONES BEFORE IT SETS CLONED? TO 1!
And that's it!
I Hope This Helps!
Create a variable and give it a name like “Cloned?” and select “For This Sprite Only”. Set it to 0 at the start and whenever the clones are deleted/reset.
Then, in the “When x key is pressed” script, put if cloned? = 0, create a clone of myself and set cloned? to 1. Don't put an else, but MAKE SURE IT CLONES BEFORE IT SETS CLONED? TO 1!
And that's it!
I Hope This Helps!
- jokebookservice1
-
1000+ posts
How to create only one clone?
That would only ever create a clone one time. I think that if you are using variables, you should make a “For this Sprite Only” variable s you mentioned, called “cloned?” and then do: Hi,
Create a variable and give it a name like “Cloned?” and select “For This Sprite Only”. Set it to 0 at the start and whenever the clones are deleted/reset.
Then, in the “When x key is pressed” script, put if cloned? = 0, create a clone of myself and set cloned? to 1. Don't put an else, but MAKE SURE IT CLONES BEFORE IT SETS CLONED? TO 1!
And that's it!
I Hope This Helps!
Now, put the if statement as you suggested, and I think that would do it.
- ECLIPSE-STUDIOS
-
100+ posts
How to create only one clone?
That would only ever create a clone one time. I think that if you are using variables, you should make a “For this Sprite Only” variable s you mentioned, called “cloned?” and then do: Hi,
Create a variable and give it a name like “Cloned?” and select “For This Sprite Only”. Set it to 0 at the start and whenever the clones are deleted/reset.
Then, in the “When x key is pressed” script, put if cloned? = 0, create a clone of myself and set cloned? to 1. Don't put an else, but MAKE SURE IT CLONES BEFORE IT SETS CLONED? TO 1!
And that's it!
I Hope This Helps!Now, put the if statement as you suggested, and I think that would do it.
Hi,
No - Every time you pressed ‘X’ it would go from 1 clone to 2 and 3 and 4 one by one - As long as you clone BEFORE setting Cloned? to 1, and I think the problem is that in his/her project, the original is cloned, then the original and the clone is cloned etc., so you end up having 1, 2, 4, 8, 16 and so on clones rather than 1, 2, 3, 4, 5 etc.
- jokebookservice1
-
1000+ posts
How to create only one clone?
Oh, I get it, each time a clone is created, it becomes responsible for creating the next clone. Must say that's a very clever method.That would only ever create a clone one time. I think that if you are using variables, you should make a “For this Sprite Only” variable s you mentioned, called “cloned?” and then do: Hi,
Create a variable and give it a name like “Cloned?” and select “For This Sprite Only”. Set it to 0 at the start and whenever the clones are deleted/reset.
Then, in the “When x key is pressed” script, put if cloned? = 0, create a clone of myself and set cloned? to 1. Don't put an else, but MAKE SURE IT CLONES BEFORE IT SETS CLONED? TO 1!
And that's it!
I Hope This Helps!Now, put the if statement as you suggested, and I think that would do it.
Hi,
No - Every time you pressed ‘X’ it would go from 1 clone to 2 and 3 and 4 one by one - As long as you clone BEFORE setting Cloned? to 1, and I think the problem is that in his/her project, the original is cloned, then the original and the clone is cloned etc., so you end up having 1, 2, 4, 8, 16 and so on clones rather than 1, 2, 3, 4, 5 etc.
- ECLIPSE-STUDIOS
-
100+ posts
How to create only one clone?
Oh, I get it, each time a clone is created, it becomes responsible for creating the next clone. Must say that's a very clever method.
Thanks - I Came Across It Trying To Fix A Game I Made, But I Ended Up Scrapping The Project Because There Were About 100 Clones Even After The Fix (And My Computer Wanted To Explode)
- deck26
-
1000+ posts
How to create only one clone?
That's OK as long as you make sure you never delete the clone before it has replicated itself. Much better, I think, to stick to only the sprite creating clones one at a time so cloneID=0 for the sprite but is immediately set to 1 in the ‘when I start as clone’ script. Then the x-key script only creates a new clone if cloneID=0. The sprite can never be deleted so this is a safer method.Oh, I get it, each time a clone is created, it becomes responsible for creating the next clone. Must say that's a very clever method.
Thanks - I Came Across It Trying To Fix A Game I Made, But I Ended Up Scrapping The Project Because There Were About 100 Clones Even After The Fix (And My Computer Wanted To Explode)
- tobkelsus
-
6 posts
How to create only one clone?
Thanks a bunch to all who helped! I learned many different ways to make this work from you guys, good job!
- 25brownc
-
1 post
How to create only one clone?
In the new update when something is cloned, the clones also duplicate. How do I make where I can just duplicate the original sprite?
- imfh
-
1000+ posts
How to create only one clone?
The clones are not also duplicated in the new update. It is likely you are using broadcasts to create clone and didn’t realize that clones also receive broadcasts. However, this topic is nearly In the new update when something is cloned, the clones also duplicate. How do I make where I can just duplicate the original sprite?4 years old so you should not be posting on it. Please create a new topic if you need more help.
Last edited by imfh (April 2, 2020 14:38:33)
- eddayavuz
-
5 posts
How to create only one clone?
I feel as though there may be some very obvious answer that I just can't figure out, but how do I continuously create only one clone? Example:
I have a script that says “When x key is pressed, create clone of myself” The first time I do it, it's fine. I go from 1 to 2 objects. But when I do it again, it goes from 2 to 4. Is there any way to make it so it only makes one copy each time? Please help!
Hey,
On this project, I place a little heart every time when the user click on the heart button. So I had the some problem and fixed it with the code below. Hope it helps:
Last edited by eddayavuz (May 5, 2020 09:50:50)
- eddayavuz
-
5 posts
How to create only one clone?
In the new update when something is cloned, the clones also duplicate. How do I make where I can just duplicate the original sprite?
I feel as though there may be some very obvious answer that I just can't figure out, but how do I continuously create only one clone? Example:
I have a script that says “When x key is pressed, create clone of myself” The first time I do it, it's fine. I go from 1 to 2 objects. But when I do it again, it goes from 2 to 4. Is there any way to make it so it only makes one copy each time? Please help!
Hey,
On this project, I place a little heart every time when the user click on the heart button. So I had the some problem and fixed it with the code below. Hope it helps:
- creatureofthedungeon
-
15 posts
How to create only one clone?
I know this thread is really old, but I just wanted to add my own solution.
I know that it's very simple, but, hey, it works.
I know that it's very simple, but, hey, it works.
- Discussion Forums
- » Help with Scripts
-
» How to create only one clone?