Get variable from external class

Remove the first if. It’s useless. Just:

AShooterGameMode* GM = Cast<AShooterGameMode>(UGameplayStatics::GetGameMode(GetWorld());
if (GM) ...