Make text disappear and stay invisible when a boolean is true

I have multiple students who, when using a solid color background, are trying to get their “instructions” text to disappear and stay hidden from user view. We tried modeling after Unit 3, Lesson 16, Level 8, however that project is using a sprite as a background, so trying to mimic that code is not working.

Link to the project or level: (Game Lab - Code.org)
What I expect to happen: I expect the user to click on the left mouse button, a sprite message to appear and the text string to disappear
What actually happens: The text string remains visible.
What I’ve tried: moving draw sprites, copying Unit 3, Lesson 16, level 8 assessment

Greetings @laurieann.lawson,

I believe that the problem arises at this part.

 if (mouseWentDown("leftButton")) {
    message.visible = true;
  } else {
    fill("white");
    textSize(11);
    text("Hover over the dog to make him dance and left click to show a secret message", 4, 200);
  }

mouseWentDown() performs when you press a button on your mouse and executes it once, therefore, making it not spammable.

So in simple terms, if you click once, it will only be true for less than a second.

To make this happen, you will have to set something in a “permanent” way until another event acts upon it.


#1. Make a variable named anything with any value (I will preferably use a boolean)
var clicked = false;
#2. In the event where you click something, change it’s value to something (I use a boolean, so I will use true)

 if (mouseWentDown("leftButton")) {
   clicked = true;
  }

3#. Then make an event if it’s that value or not (like I said I’m using a boolean, so it might be different than yours)

if (clicked == true) {
 message.visible = true;
} else {
 text("put something here", x, y);
}

I hope this has helped you!

Thank you!! This helped a lot getting it all figured out!