How to make code run only the first time somebody plays

So, do you want to make a tutorial, but make it so players only have to go through it if they’ve never played before? Or a special reward for people who’ve played 10 times? Well, you’re in luck! That’s what I’ll be teaching today.

1. So first we need to make a blank text object, like this.


2. Open the object’s code and select ‘when game starts’. Select the yellow ‘increase’ block and create a user variable (advanced mode only). Set the number to one, so your code looks like this:

3. Below the yellow increase block, add a blue ‘check if else’ block.

4. Select ‘=‘ and in the left bubble, select your user variable, and in the right, type ‘1’.

5. In the top section of the check once if block, put whatever code you want to run if it’s somebody’s first time playing; in the bottom; put the code you want if they’ve played before. I’ve put some different text.

It’s done! Easy, right? Play the project multiple times- experiment! What can you do?

@Strikers

13 Likes

stealing first post. does this tutorial make sense to you?

5 Likes

Yes. Don’t have advanced mode though.

5 Likes

The only way that i know of to save things in games is user variables-

6 Likes

That is true

5 Likes

cool! don’t have advanced mode though, but would totally try this

5 Likes

Very nice guide — easy-to-follow with clear steps and screenshots :smiley:

Another small suggestion I would have is that people can name the variable “Plays” or “Number of Plays”, if they get to a point where they’re starting to have a lot of variables.

So if “Number of plays” = 1, you know this is the first time the scene is being played.

8 Likes

And if the game is larger you could even create a badge commemorating the 10th, 20th, and 100th times played!

Love the tutorial!

3 Likes

Nice! I have something almost exactly like this in some of my games! (I’m not saying you copied me btw lol)

3 Likes

Hmmm, do you do if Variable does not equal 2 set to 0 and increase by 2 and than so on?

2 Likes

That still needs user variables. Its the same thing except its all 2s

2 Likes