Why is cloning not working?

Cloning seems buggy in my snap project. Most of the time it will create the clone, but in random circumstances it just doesn't work. It happens about 30% of the time. I even added a debug variable that adds 1 above the "create a clone of myself" block to be sure the message was being broadcasted and getting through the if statements. Please focus on the "change debugger1 by 1" and "create a clone of myself" blocks:

Script Pic 1

To my surprise, debugger1 got changed by 1 but nothing was cloned. This has me suspecting the clone block is bugged. Just to be sure, I added this block as well:

Script Pic 2

debugger1 gets changed by 1 and debugger2 is unaffected, despite being told to clone itself and add to debugger1 in the same script. (Again, this happens about 30% of the time).

I'm only creating a few clones in my project, so it's definitely not a clone-limit.

Why isn't it cloning? Is there something about clone blocks I'm missing here?

Are you sure you only have a small number of clones? There may be clones from other sprites within your project. One way to discover how many sprites (incl. clones) your project has is by calling:

clone exponentiator script pic

If it's anywhere near 5,000 you may still have bumped into the clone limit, somewhere in the process.

Or you may share a link to your project, such that others can have a look.
For comparison, this is my little test project.

BTW - you've been using:

clone exponentiator script pic (2)

... , which doesn't report success or failure. If you want to be sure of what's actually happening, you'd better use:

clone exponentiator script pic (3)

Thank you so much.

Odd enough, replacing:

Script pic 1


Script pic 2

fixed my issue and it successfully clones every time. I made no changes to the other scripts.

Don't switch costume to a clone, you should set the clone to a variable, or use an ignore block.

Untitled script pic (63)

untitled script pic


I have the original sprite hidden so switching costumes works for me, but other people with this issue will want to make this ignore block instead.

It actually doesn't work; it just fails without giving an error message, Scratch-style. Costumes and sprites are two different kinds of things; SWITCH TO COSTUME requires a costume as input (or a bitmap, which will be taken as a costume with the current height and width), not a sprite.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.