Setting Image Visibility based on player input - C++

Hey! So, I have two classes I want to interact with each other for this; I’m using the outdated input system, I will admit, but this shouldn’t be a problem? Either way, I’ve created the binding in code (images below), and ive got two images. I have one set to hidden to default, one visible at the start of the game.

I want it so that when the player presses 1, they see the initial image, and when they press 2, they see the second image and the default image gets hidden. The code runs; but it crashes unreal when pressing 1 or 2 in game.


image
image

I hope all relevant info has been provided? I havent used blueprints because this is for a coding assignment, besides to set the text (like current/max ammo) because that was being weird with c++.

Alternatively, this doesn’t have to be done with c++, it’s just preferable.