Clones and Self Variables [Tutorial] (Posts 1-2)


Hello! Do self variables and clones confuse you? Me, @intellection74, @mr.gam3r, and @Petrichor teamed up to make this tutorial! We will tell you what self variables are good for, how self works, and an overview of clones. Let's get started!

What are self variables good for for?

Self variables are good for lots of stuff including
* Games
* Spiral art
* 3Dish objects
And much more. There is also a self reference in certain "when" blocks, but after reading everything here you should understand it. I will give a simple example of using self Variables to store five unique variables in a clone using @Valgo's fast cloning method.
First, add this code:

Then, add this code:

Oh, right. They all end up being zero! Let's fix that.

Now there is the example!

If you have any questions about this part of the tutorial, tag @Petrichor.

How Self works

When you put an object in a variable bubble, it refers to that object.

If that object has clones, it refers to the main/original object, the one that is on the stage editor and was cloned.

When you use Self in a bubble, it refers to the main object, and all of the clones as well.

This code means if the main Chillanna is tapped, the Happiness will increase.

In this code, any Chillanna can be tapped.

Using certain code, you can use Self to refer to a single object. In this example, the sixth clone's happiness will be set to 50. (Ignore the other code)

Clones Overview

So, before you dive into learning about self variables, you need to know a thing or two about using Clones on Hopscotch. When you create a clone of an object you're creating an exact copy of the original object. In this example project, we're going to make some Clones scatter randomly on the screen and turn a random color.

First, add a shape object, and create fifty clones when the game starts. Next, add a rule below the repeat block, and set the clones to a random position on the screen and a random color.

Let's see what happens!

Hm... that doesn't look right. XD What happened? Aren't the clones supposed to do exactly what the original object does? Well, only the original object does things in the rule that the clones were made in. Let's tweak that rule a bit:

And here's the result! :smiley:

Yay! It worked!! How about we make all of the Clones spin once they're all created? Add the following code:

Notice how all of the clones turn, not just certain ones. You can use self values to individualize a certain clone. Keep reading to learn about self values!
If you're confused about this part of the tutorial (or anything much about the basics of clones) please tag me, @Intellection74! The spiral draw Hopscotch video tutorial has some good information about Clones, so if you don't get something you could also check that out (also, here is the example project I explained if you would like to see it) :smile: Don't be afraid to experiment with Clones. They can be confusing, but it's so fun to mess around with them and explore new things!! Have fun guys!

I need help with clones!
Hopscotch Academy - Always accepting new students and teachers!
How to make a drawing pad with clones
The variable self
Cloned art pad?

helpful links

Here are some links to other helpful topics about self variables and clones!

If you find more links that you think should be added here, tag @bluedogmc-official

Thanks for reading! We hope you like this tutorial! Reply with any questions, comments, etc. We each wrote a part of this, so if you have a question about a specific paragraph, tag the writer of that paragraph!

~ the tutorial collab team

Mimi's General :))

Awesome topic! Are your fingers OK?


Lol yah. I worked with a few other people listed above to make this, so luckily I didn't have to type all of it. Thanks!


Oh, what a relief. I'm making a topic rn, and my fingers are pooped;-;

I saw that edit




Great topic! I'll bookmark this!


Amazing topic, it is really helpful! I don't code with the self-version, so if I will try self sometime this will really help me!


Great tutorial, @Petrichor @mr.gam3r @Intellection74 @bluedogmc-official! :P


Thank you. I stayed up later than usual working on my part.


This is awesome :smile:

thanks for mentioning this too @Petrichor I hadn't heard about this and it sounds pretty handy, so thanks @Valgo too!