# Replicated Tsubclass in PlayerController causes Player State not syncing

**URL:** <https://forums.unrealengine.com/t/replicated-tsubclass-in-playercontroller-causes-player-state-not-syncing/440596>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, playerstate, tsubclassof, unreal-engine, UE4, CPP, question\
**Created:** [January 4, 2019, 11:29am UTC](https://forums.unrealengine.com/t/replicated-tsubclass-in-playercontroller-causes-player-state-not-syncing/440596 "2019-01-04T11:29:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JakeTee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JakeTee](https://forums.unrealengine.com/u/JakeTee)\
**Post date:** [January 4, 2019, 11:29am UTC](https://forums.unrealengine.com/t/replicated-tsubclass-in-playercontroller-causes-player-state-not-syncing/440596/1 "2019-01-04T11:29:32Z")

</div>

Hey guys, I have a really strange problem here that I don’t seem to find a way to solve.  
Basically, I have a PlayerController class with replicated TSubclass.  
MyPlayerController.h

```
    UPROPERTY(Replicated)
    TSubclassOf<APawn> MyClass;

```

MyPlayerController.cpp

```
void AMyPlayerController::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	DOREPLIFETIME(AMyPlayerController, MyClass);
}

```

And then when I play test, with print string every tick from the player controller blueprint inherited class - print the playerstate name, playerstate is null from the client and still valid on the server.

 ![264136-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/9/0392db8c68c429cbec394ca5545d40a11c55bc92.png)

If I do the samething with blueprint, everything works fine. I don’t know whether this is a bug or I have done something wrong ☹

---

<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 4, 2019, 12:29pm UTC](https://forums.unrealengine.com/t/replicated-tsubclass-in-playercontroller-causes-player-state-not-syncing/440596/2 "2019-01-04T12:29:53Z")

</div>

A PlayerController can only be replicated to the owner so perhaps you are looking at the Server Character? Client1 will never know what is on the server player controller.

---

<div class="post-metadata">

**Author:** ![JakeTee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JakeTee](https://forums.unrealengine.com/u/JakeTee)\
**Post date:** [January 4, 2019, 1:01pm UTC](https://forums.unrealengine.com/t/replicated-tsubclass-in-playercontroller-causes-player-state-not-syncing/440596/3 "2019-01-04T13:01:28Z")

</div>

You got point. After doing some more research, found out that like you said, the replicated variable only replicated to the owner aka local controller not server controller. So therefore I have moved that variable to playerstate since playerstate is visible to all clients 😃 Thanks for your hint.
