UProperty(Replicated) Not working

All caps UPROPERTY did the trick… can’t believe I didn’t see that, “Net/Un…” wasn’t required for the code that I have now but is there a reason I might have to include it now for future reference?

Hello, First post on the forums, I just needed some insight on why my C++ code isnt compiling correctly. I’m following a tutorial online to better understand C++ and BP Networking. I created a new C++ GameState class and I’m trying to replicate two variables but I get these errors.

Here’s a look at my GameState header

#pragma once

#include "GameFramework/GameState.h"
#include "UnrealNetwork.h" // You need this include to get the Replication working. Good place for it would be your projects Header!
#include "Engine.h"
#include "CPP_GameState.generated.h"

/**
 * 
 */
UCLASS()
class TESTPROJECT_API ACPP_GameState : public AGameState
{
	GENERATED_BODY()
		// Replicated Specifier used to mark this variable to replicate

	UProperty( replicated )
		int32 TeamAScore;

	UProperty(Replicated)
		int32 TeamBScore;
	
	// Function to increase the Score of a Team
	void AddScore(bool TeamAScored);
};

And my cpp file

#include "TestProject.h"
#include "CPP_GameState.h"

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

	DOREPLIFETIME(ACPP_GameState, TeamAScore);
	DOREPLIFETIME(ACPP_GameState, TeamBScore);
}

void ACPP_GameState::AddScore(bool TeamAScored)
{
	if (TeamAScored)
	{
		TeamAScore++;
	}
	else
	{
		TeamBScore++;
	}
}

I’m slightly new to UE4 C++ programming so if it’s something so obvious I apologize ! But I appreciate any and all responses. Thank You for your time !

UPROPERTY must be in all uppercase, it is case-sensitive (like anything in C++).

Also, for GetLifeTimeReplicatedProps you need to include “Net/UnrealNetwork.h” in your cpp.

No, I see you’re already including it in your header.