# Replicating a variable in a custom AGameState breaks playercontroller on client

**URL:** <https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, Replication, gamestate, unreal-engine, CPP, question\
**Created:** [December 20, 2016, 11:10am UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788 "2016-12-20T11:10:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aa1000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aa1000](https://forums.unrealengine.com/u/aa1000)\
**Post date:** [December 20, 2016, 11:10am UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/1 "2016-12-20T11:10:49Z")

</div>

When I put a replicated variable in a custom C++ AGameState and connect through a session ,the server PlayerController spawns normally but the game breaks on the clients, I’m sure that the BeginPlay() event is not called on all of them no matter what I try.

---

<div class="post-metadata">

**Author:** ![Holybreath](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holybreath](https://forums.unrealengine.com/u/Holybreath)\
**Post date:** [December 20, 2016, 11:43am UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/2 "2016-12-20T11:43:27Z")

</div>

I’m sure there’s a different reason for such behavior. Need more detail. What variable , what it does, are there any methods like OnRep stuff, that may do something funny.

---

<div class="post-metadata">

**Author:** ![aa1000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aa1000](https://forums.unrealengine.com/u/aa1000)\
**Post date:** [December 20, 2016, 1:35pm UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/3 "2016-12-20T13:35:30Z")

</div>

Pretty much any replicated variable with GetLifetimrReplicated breaks the clients, even standard types like float or int32. I don’t get any compiling errors.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [December 20, 2016, 1:53pm UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/4 "2016-12-20T13:53:20Z")

</div>

Are you calling the Super for GetLifetimeReplicatedProps?

Such as:

```
void AActor::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const
{    
    Super::GetLifetimeReplicatedProps( OutLifetimeProps );
    DOREPLIFETIME( AActor, Owner );
}

```

---

<div class="post-metadata">

**Author:** ![aa1000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@aa1000](https://forums.unrealengine.com/u/aa1000)\
**Post date:** [December 20, 2016, 6:03pm UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/5 "2016-12-20T18:03:51Z")

</div>

I think i forgot that, I can’t replicate the problem because i changed my code around using the game state, but that might have been it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfdc89c91](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfdc89c91](https://forums.unrealengine.com/u/anonymous_user_cfdc89c91)\
**Post date:** [April 14, 2020, 3:49am UTC](https://forums.unrealengine.com/t/replicating-a-variable-in-a-custom-agamestate-breaks-playercontroller-on-client/379788/6 "2020-04-14T03:49:07Z")

</div>

I had the same issue, and I had indeed forgot to call Super in GetLifetimeReplicatedProps. Good call.
