How to extend functions in GameMode class?

Do you have TeamPlayerController.h added in your header file?

To always be sure the right headers are included create a c++ class from the editor: Using the C++ Class Wizard in Unreal Engine | Unreal Engine 5.1 Documentation