How do I get a line of code to stop but without stopping the entire cospace code

from the bottom of my heart thank you

No problem, thanks to you.

Same to you have a good day and I will come to you or this community with any of my Q&A thank you agian.

1 Like

Umm hello I’m having a bit of trouble
I’m trying to code a a chest being locked by a code
The place to enter code activates when the chest is clicked on
But after the code is entered correctly clicking on the chest again trigger the code response again.
So I was wondering if u knew how to disable a code after it ran
Btw I’m not using any loops or anything
If u could help me I will be rlly grateful


This the code I was working on
It’s rlly long cuz it’s designed in a way that if u get any number wrong twice in a row it makes u lose which ends a few scenes later but anyway

@Ash2080 you can create a variable called chestIsClosed and set it to true at the start of the game, then checking through an “if” statement if the chest if closed before starting the code for the lock like so:

Uhh I tried and it’s not working


This is the changed block of code

At the top of the code I have placed a set “chestisClosed” to true
But u can’t see that here

Move the orange if statement inside the yellow block @Ash2080, and with all of the purple inside of it.
The yellow block initiates the event (meaning the computer will from that moment on check if the chest is clicked and run the code inside it if it has). Now the event will be initiatated if the chest is closed, but it will stay initiated regardless of if anything changes. By moving the if statement inside the block then whenever the chest is clicked it will first check if the chest is closed before going on with the rest of the code inside the block. Hope to have helped!

Yes it worked. Thank you so much. I was struggling a bit even though it sounded like a simple fix but thanks a lot.

1 Like