I want to make a button deal damage to me

I am creating a basic puzzle, the player needs to solve a riddle. The answer being a number. The number then corresponding to a button on a wall.

I want to make the player take damage every time they push the wrong button. How do I go about doing this. I am new to UE4 Blueprints so if someone could show me how to do this as well as explain it, I would much appreciate it.

This might be helpful to you if you are new to the engine. Really beginner friendly tutorial series that goes over the basics of blueprints.

As for your specific question check out this video should help you with widget communications.

Sorry, I should have specified. The button I am referring to is an 3D object in the game. Its not a click either. The player would move their cross hair over the button and press E to push it. If its the wrong button, the player will take damage. If its the right button, the player wont take damage.

The correct button uses a different blueprint from the 10+ wrong buttons. The correct one is only different by the fact that when pressed, a sound is played and a matinee starts that opens a gate. The wrong buttons all use the exact same BP. It only has a text script in it to display “Press E to Push”.

Really doesn’t matter. The concepts are the same. You are going to need to cast, create references and navigate through widgets to do this. My second video goes from 1 widget to another because this is usually the most difficult thing for those unfamiliar with how to navigate that chain of communication since widgets don’t exist in the world interacting with them can be more of a challenge. However, as I said, the “concept” is the same. You have a 3D button, the player locates this button with the cross hair, a line trace or something is fired out and contacts the target button. You can break the line trace hit result and get a reference to the specific button it hit. With that reference you can call functions/custom events you create within the 3D button blueprint. If it is the correct button the function/custom event will play a matinee, the sound and open a door etc etc. If it is the wrong button it will instead damage the player. So the function/custom event to damage the player would then need to grab a reference to the player (get player character → cast to X character BP) and pull out the health variable and take off however much damage you want then set that health variable once it is complete to the reduced value. I hope that makes sense.

You could try a line trace upon pressing E, to which if the hit actor is the “wrong button” the character takes damage.