Discuss Scratch

tobkelsus
Scratcher
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!
jokebookservice1
Scratcher
1000+ posts

How to create only one clone?

You could make a script like this:
whenclickedforeverifkeyxpressed?thencreatecloneofmyselfwaituntilnotkeyxpressed?
This will have some differences to the hat block, though it should be fine
ECLIPSE-STUDIOS
Scratcher
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!
jokebookservice1
Scratcher
1000+ posts

How to create only one clone?

ECLIPSE-STUDIOS wrote:

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!
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:
whenIstartasaclonesetcloned?to1
Now, put the if statement as you suggested, and I think that would do it.
ECLIPSE-STUDIOS
Scratcher
100+ posts

How to create only one clone?

jokebookservice1 wrote:

ECLIPSE-STUDIOS wrote:

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!
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:
whenIstartasaclonesetcloned?to1
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
Scratcher
1000+ posts

How to create only one clone?

ECLIPSE-STUDIOS wrote:

jokebookservice1 wrote:

ECLIPSE-STUDIOS wrote:

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!
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:
whenIstartasaclonesetcloned?to1
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.
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.
ECLIPSE-STUDIOS
Scratcher
100+ posts

How to create only one clone?

jokebookservice1 wrote:

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
Scratcher
1000+ posts

How to create only one clone?

ECLIPSE-STUDIOS wrote:

jokebookservice1 wrote:

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)
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.
tobkelsus
Scratcher
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!
xXAlphaWolfDragoXx
Scratcher
1 post

How to create only one clone?


deck26
Scratcher
1000+ posts

How to create only one clone?

xXAlphaWolfDragoXx wrote:


Please don't spam or necropost.
Teddy_Bear3
Scratcher
42 posts

How to create only one clone?

whenclickedforeverifkeyxpressed?thencreatecloneofmyselfwaituntilnotkeyxpressed?
deck26
Scratcher
1000+ posts

How to create only one clone?

Teddy_Bear3 wrote:

whenclickedforeverifkeyxpressed?thencreatecloneofmyselfwaituntilnotkeyxpressed?
Please check the date before posting.
25brownc
Scratcher
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
Scratcher
1000+ posts

How to create only one clone?

25brownc wrote:

In the new update when something is cloned, the clones also duplicate. How do I make where I can just duplicate the original sprite?
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 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
Scratcher
5 posts

How to create only one clone?

tobkelsus wrote:

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:

whenclickedsetinstancetosprite

whenIstartasaclonesetinstancetoclone

whenIreceiveplacelittleheartscreatecloneofmyselfgotorandom positionifinstance=clonethendeletethisclone

Last edited by eddayavuz (May 5, 2020 09:50:50)

eddayavuz
Scratcher
5 posts

How to create only one clone?

25brownc wrote:

In the new update when something is cloned, the clones also duplicate. How do I make where I can just duplicate the original sprite?

tobkelsus wrote:

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:
whenclickedsetinstancetosprite

whenIstartasaclonesetinstancetoclone

whenIreceiveplacelittleheartscreatecloneofmyselfgotorandom positionifinstance=clonethendeletethisclone
creatureofthedungeon
Scratcher
15 posts

How to create only one clone?

I know this thread is really old, but I just wanted to add my own solution.


whenclickedsetam_I_a_cloneto0

whenIstartasaclonesetam_I_a_cloneto1

WheneveritisthatIwanttocreateacloneifam_I_a_clone=0thencreatecloneofmyself

I know that it's very simple, but, hey, it works.

Powered by DjangoBB