Problem with UObject replicaiton

Hello everybody, I need to replicate my UObject from server to client, what I do wrong? On the server side data is UObject is valid on the client side - not.
Below my replication code: (UObject and AActor)

ItemObject.h

#pragma once

#include "CoreMinimal.h"
#include "Core.h"
#include "Object.h"
#include "ItemObject.generated.h"

UCLASS(Blueprintable)
class MYGAME_API UItemObject : public UObject
{
	GENERATED_BODY()
	UItemObject(const class FObjectInitializer& ObjectInitializer);
public:
	
	UPROPERTY(Replicated)
	uint32 bReplicatedFlag : 1;

	virtual bool IsSupportedForNetworking() const override
	{
		return true;
	}
	
};

ItemObject.cpp

#include "ItemObject.h"
#include "UnrealNetwork.h"
#include "Engine.h"

UItemObject::UItemObject(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
}

void UItemObject::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(UItemObject, bReplicatedFlag);
}

MyPlayerController.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "Core.h"
#include "ItemObject.h"
#include "MyPlayerController.generated.h"

/**
 * 
 */
UCLASS()
class MYGAME_API AMyPlayerController : public APlayerController
{
	GENERATED_BODY()
		AMyPlayerController(const class FObjectInitializer& ObjectInitializer);
public:

	virtual void PostInitializeComponents() override;
	virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override;

	/** A Replicated Subobject */
	UPROPERTY(Replicated)
	UItemObject* Subobject;

private:
		
};

MyPlayerController.cpp

#include "MyPlayerController.h"
#include "UnrealNetwork.h"
#include "Engine/ActorChannel.h"
#include "ItemObject.h"


AMyPlayerController::AMyPlayerController(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	bReplicates = true;
}

void AMyPlayerController::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	if (HasAuthority())
	{
		Subobject = NewObject<UItemObject>(this);
	}
}

bool AMyPlayerController::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags)
{
	bool WroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);

	if (Subobject != nullptr)
	{
		WroteSomething |= Channel->ReplicateSubobject(Subobject, *Bunch, *RepFlags);
	}

	return WroteSomething;
}

void AMyPlayerController::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(AMyPlayerController, Subobject);
}

I can’t see anything wrong with this, what do you mean by the data on the client being being invalid? You don’t even get the object?

It looks fine in quick glance. It does take a few fractions of a second for Objects to replicate from the server. If you are not already; perform a Validation Check before using the sub object to ensure you do not crashing the game. It… should… replicate down.

Other than using GameState instead of player controller i have the same setup and it does not replicate the uobject. :frowning:

Ok so I found the missing part which would make the code work

You have to set this flag when creating the uobject that you want replicated RF_Public

I referenced this post here since it is a nearly perfect example for UObject Replication (Except the part that is replicating values on PlayerController which i think is not a good standard).

https://forums.unrealengine.com/t/uobject-eligible-for-replication-guide/671679/2