I can't figure out why my cast returns nullptr

Maybe a cast to APlayerController then check for IsLocalController() first before doing another cast to AMyPlayerController. It works for me.