How to make a button that works as a light switch

Hello everyone, so I have made a button that looks like a light switch. I made the switch itself to work like a button as I want it to turn a light on and off. But I am currently having an issue with this. I currently only got two animations for this button, the switch going up and the switch going down. The animations aren’t working correctly as well. I seem to be having a hard time making this all work the way a normal light switch would work as in real life.

Simply, I want this button to work as the following:

  • Right click button
  • Animation change when clicked each time + Light on/off
  • Real light switch effect

As always, all help is highly appreciated. :slight_smile:

I think I’ll mention all of the people who helped me make my game if they would like me to. (I’ll send all those who helped a PM asking)

I made a simple example: (32.3 KB)
Note 1: I don’t know the conditions you need, my conditions are mouse over switch and left click.
Note 2: “Mouse_pressed” variable to avoid turn on-off multiple times if mouse click get pressed.
Note 3: “check_sub” variable to avoid double sub_event running (if anim = 0 set anim = 1 ==>True then if anim = 1 set anim = 0 ==> True)

Let me know any questions :slight_smile:

Thanks man, would this also possibly work like a mute button. Because currently I got a mute button on the main menu of my game. But you have to click M to mute and U to unmute. I have been trying to figure out how to make the mute button be properly clicked and work like an actual mute button.

Of course, just change the actions related to light’s intensity by actions related to the global volume :slight_smile:

Oh ok, thanks for the information man. :slight_smile:

Also, another thing, would you like me to mention your name in the credits section of my game?

Oh, that isn’t necessary, help you is enough (for me) :wink:

Ok, I just wanted to make sure. :slight_smile: