Discuss Scratch

CocoGoldie789
Scratcher
16 posts

How can I make the clone command only make 1 clone each time?

I have a “cash” sprite. When you click it it disappears and adds 1 to “money” variable. “cash” spawns when you click a button. If I click it, 1 cash appears. If I click it again, 2 more appear. When I click it again, like 3 cashes all appear at once. How can I make the clone command make 1 clone of something no matter how many other clones there are?
RT_Borg
Scratcher
1000+ posts

How can I make the clone command only make 1 clone each time?

Hi CocoGoldie789,

It may be that you have the Cash sprite creating clones, so if there are already clones, in addition to the original non-clone, they each create a clone of themselves.

The two ways to solve this are:
  1. Have some other sprite you know there is just one of create the clones of Cash
  2. Give clones ID values (say from 1 up) and have an if statement to only let the original sprite (say ID = 0) create new clones.

If you share a link to your project, people can give you more specific advice.

– RT_Borg
deck26
Scratcher
1000+ posts

How can I make the clone command only make 1 clone each time?

You can also use cloneIDs in a simple fashion - make the sprite have cloneID=0 and all clones have cloneID=1. This is easily done by setting cloneID to 1 at the top of the ‘when I start as clone’ script. No need in this case to number clones individually.
RT_Borg
Scratcher
1000+ posts

How can I make the clone command only make 1 clone each time?

Ah, clever deck26.

(is-clone) // for this sprite only

when green flag clicked
set [is-clone v] to [false]
...

when I start as a clone
set [is-clone v] to [true]
...
Gradees
Scratcher
14 posts

How can I make the clone command only make 1 clone each time?

I've had this problem and what I did is when I wanted to create a clone, I broadcasted something, then in a different sprite, put the when I receive the broadcast, create a clone of whatever you need.

game im currently working on
https://scratch.mit.edu/projects/698221879/
please play it
CocoGoldie789
Scratcher
16 posts

How can I make the clone command only make 1 clone each time?

RT_Borg wrote:

Hi CocoGoldie789,

It may be that you have the Cash sprite creating clones, so if there are already clones, in addition to the original non-clone, they each create a clone of themselves.

The two ways to solve this are:
  1. Have some other sprite you know there is just one of create the clones of Cash
  2. Give clones ID values (say from 1 up) and have an if statement to only let the original sprite (say ID = 0) create new clones.

If you share a link to your project, people can give you more specific advice.

– RT_Borg
thank you. your first method worked!

Powered by DjangoBB