# C++ replication crash.

**URL:** <https://forums.unrealengine.com/t/c-replication-crash/1704019>\
**Category:** Programming & Scripting\
**Tags:** Replication, unreal-engine, CPP, question\
**Created:** [February 21, 2024, 3:58pm UTC](https://forums.unrealengine.com/t/c-replication-crash/1704019 "2024-02-21T15:58:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NaranjaJuyas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NaranjaJuyas](https://forums.unrealengine.com/u/NaranjaJuyas)\
**Post date:** [February 21, 2024, 3:58pm UTC](https://forums.unrealengine.com/t/c-replication-crash/1704019/1 "2024-02-21T15:58:44Z")

</div>

Hi guys, Im trying to create a simple Actor with replication.

This is my header file

```auto

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Clock.generated.h"

UCLASS()
class VISUALTEST_API AClock : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties

	AClock();

	UFUNCTION(BlueprintCallable, Category = "Clock")
	void UpdateClock();

	virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const override;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	FTimerHandle TimerHandle;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Clock", Replicated)
	int32 hour;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Clock", ReplicatedUsing = OnRep_Minute)
	int32 minute;

	UFUNCTION()
	void OnRep_Minute();

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;
};

```

And this is my .cpp file:

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#include "Clock.h"
#include "Net/UnrealNetwork.h"
#include "Engine/Engine.h"
// Sets default values
AClock::AClock()
{
 	// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	bReplicates = true;

	hour = 8;
	minute = 0;
}

// Called when the game starts or when spawned
void AClock::BeginPlay()
{
	Super::BeginPlay();
	if (GetLocalRole() == ROLE_Authority)
	{
		GetWorldTimerManager().SetTimer(TimerHandle, this, &AClock::UpdateClock, 7.5f, true);
	}
	
	
}

// Called every frame
void AClock::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void AClock::UpdateClock()
{
	minute = minute + 15;
	if (minute >= 60)
	{
		minute = 0;
		hour++;
		if (hour >= 24)
		{
			hour = 0;
		}
	}
}

void AClock::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(AClock, hour);
	DOREPLIFETIME(AClock, minute);
}

void AClock::OnRep_Minute()
{
	FString TimeString = FString::Printf(TEXT("%d:%d"), hour, minute);
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TimeString);
}

```

Everytime I run the engine, I get this error and I have not found too much information on how to solve it:

Assertion failed: bIsValid [LocalPath] [Line: 184] UHT Generated Rep Indices do not match runtime populated Rep Indices for properties in AClock

What I am doing wrong?

---

<div class="post-metadata">

**Author:** ![CicarioPlusPlus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CicarioPlusPlus](https://forums.unrealengine.com/u/CicarioPlusPlus)\
**Post date:** [February 13, 2026, 6:24pm UTC](https://forums.unrealengine.com/t/c-replication-crash/1704019/2 "2026-02-13T18:24:40Z")

</div>

I had the same problem.

I tried to delete Binaries, Intermediate, and Saved folders in the project folder. Then I right-clicked on uproject-file and chose Generate Visual Studio project files. After that I ran UE5.3 editor and was promted to compile missing modules. I chose Yes, and restarted UE5.3 editor.

It works for me
