ugameplaystatics::getplayercharacter(GetWorld(), 0)->GetName() crashes editor

I just found out that ugameplaystatics::getplayercharacter(GetWorld(), 0) is a null pointer. I’m not sure why though. I can get a non null pointer if I do:

FString PawnName;

for (TActorIterator<APawn> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
    APawn *pawn = *ActorItr;
    PawnName = ActorItr->GetName();
}