# How do i make custom GameState work?

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-custom-gamestate-work/460821>\
**Category:** C++\
**Tags:** gamemode, gamestate, unreal-engine, UE4, CPP, question\
**Created:** [January 21, 2020, 8:44pm UTC](https://forums.unrealengine.com/t/how-do-i-make-custom-gamestate-work/460821 "2020-01-21T20:44:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdul\_Hasan\_Ali](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Abdul\_Hasan\_Ali](https://forums.unrealengine.com/u/Abdul_Hasan_Ali)\
**Post date:** [January 21, 2020, 8:44pm UTC](https://forums.unrealengine.com/t/how-do-i-make-custom-gamestate-work/460821/1 "2020-01-21T20:44:21Z")

</div>

I added a custom GameState class that overrides the AGameState class.  
I just added the following code:

```
 ATanksGameState::ATanksGameState()
    {
    }

void ATanksGameState::HandleBeginPlay()
{
	Super::HandleBeginPlay();
	GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, FString::Printf(TEXT("state begin play")));
}

```

The message is printed when i start the game, but i don’t possess any player anymore or anything. Basically nothing works anymore. Do i have to change something related to the gamemode class or something else?

I still have the default gamemode class, that inherits gamemodebase, and added no code to it.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![GarnerP57](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarnerP57](https://forums.unrealengine.com/u/GarnerP57)\
**Post date:** [January 21, 2020, 9:41pm UTC](https://forums.unrealengine.com/t/how-do-i-make-custom-gamestate-work/460821/2 "2020-01-21T21:41:47Z")

</div>

When you use GameMode **Base** you have to use GameState **Base** and when you use GameMode you need to use GameState. They go hand in hand.
