Please help a student debug this!

CoSpaces Edu :: Video Games, January 2022 Scene 2. A student asked me this, and I nor any other student can help fix it.

We are attempting to make a game where doors can be closed when pressing buttons. The green button opens the door and the red button closes the door. When the door is closed the power drains. The problem is that when the buttons are spammed the energy system stops working. We’ve tried to fix this by moving the buttons when they’re pressed and then moving them back when the other button is pressed (see cubefix in the code). For whatever reason, moving the buttons or changing their transparency breaks the rest of the code that has to do with the button like the door animations and energy system. We’ve also tried to create variables that don’t allow the player to click the button until the other button is pressed. This theoretically should’ve made it so that the player would be forced to alternate between clicking the green and red buttons but as long as you don’t move your cursor off of the button, you can keep spamming it, breaking the energy system.


Hello, if I understand your problem you want to make sure that the opening animation is not activated several times with the spam keys. To solve this problem just enter the click commands inside two forever commands (linked by a parallel) with inside an if condition that runs the animation of opening only if the var is true (using the green button) and the animation of close if the var is false (using the red button). Hope my respons will help your student.


Kelly, if this doesn’t work, let us know. Did you make changes since you posted? I see some code changes.I might have copied the old version. Can you please update?


How are we doing? Let us know if it is resolved.