How do I use a Game Instance to have a global variable, or what's an alternative method to accomplish what I want to do?

I’m modifying the base FPS game project and I’m trying to make it so that when the player hits an enemy with a projectile from their gun, they gain back their ammo. My general idea for doing this was a variable that gets changed when a player projectile hits an enemy. What is the most straightforward way to do this? From what I found online, using a Game Instance to create a global-ish variable might work, but I can’t figure out how to do it.

Remember to initialize the PlayerAmmo variable with a starting value at the beginning of the game, and ensure that your HUD or ammo display is updated whenever the ammo count changes. Open MyGameInstance and add a new variable, let’s call it PlayerAmmo. Set the variable type to Integer and make it public so other Blueprints can access it. When a hit is detected, cast to MyGameInstance and increase the PlayerAmmo variable by the desired amount. In your player Blueprint, you can access the PlayerAmmo variable by casting to MyGameInstance.

Event Hit (On Projectile Blueprint)
Cast to MyGameInstance
Get PlayerAmmo
Set PlayerAmmo (PlayerAmmo + AmmoReward)

Event Any (On Player Blueprint)
Cast to MyGameInstance
Get PlayerAmmo
Update Ammo Display

Thank you!! That seems to have worked.