HUD Class grayed out, cant select

That is because the HUD is selected based off the game mode. You either need to edit the existing game mode to use your HUD or create a new game mode that uses your HUD and set it as the active game mode in the world settings.

I created a blueprint HUD class so that I can display variables, but I’m having trouble selecting the new HUD. I went to world settings, but the ability to select the HUD Class is grayed out.

Ah ok, I was able to add it to the game mode through the c++ code.

i also have the same problem ,can you tell me how to edit it in the c++ code?

I think this happens if your game mode class is a C++ implementation. In any case you can in your constructor or BeginPlay() of your Game Mode class do:

HUDClass = YourCustomHUDClass::StaticClass();

This should assign the HUD to your gamemode

Found a possible workaround by adding a component, and then dragging the correct one on top of the default one.