Variable CoBlocks

Hello Guys, So I am new in CoSpaces. I create a cospaces that they have 2 keys and door. The door must be open if the 2 keys is collected. But it didn’t work. Could u have some troubleshoot?
Key an Door

Hi @dimas.yoga, you were actually on the right track;

The problem with your cospace was that the block that checks if the player has 2 keys only happens once at the start of the game. Instead you must define when to check specifically, either through a loop or in this case I put your “if has 2 keys” block inside of an on click event of the pad lock.

So that now whenever you click the padlock it will tell you if you dont have enough keys, or let you through if you have both.
(I have changed the method for checking to using whats known as a “boolean” this is a variable that is either true/false; So at the start of the game the player is assigned 2 variables, “hasKey1” and “hasKey2” both are set to “False”, then when they pickup the respective key this variable is set to “True”. Which makes the keypad statement easier to read/use: “If hasKey1 and hasKey2, remove padlock and open door, else tell player they need both keys”.

Hope to have helped!

you was so close.
Turn off physics on the lock.
image
image

Hope it helps you!