HUD Replication problem

Hi

Im trying to build a small application in which I run a dedicated server and I have two clients with a simple hud.

This hud is made with two buttons.

“Join blue team”
“Join red team”

When they press one of the two they will swap their hud to the specific one depending on the blue and the red one.

that is how it should work.

But right now, if I press in one client “red” and in the other “Blue” one of the two clients receive both HUDs and the other none. Also I print one message “Button clicked!” and every time one of the two press it both receive the message.

The code is like that:

Construct:

`void SDB_XWidget::Construct(const FArguments& InArgs)
{
	OwnerHUD = InArgs._OwnerHUD;
	CurrentPlayerController =  Cast<ADB_XPlayerController>(OwnerHUD->PlayerOwner);
	
	FightContainer = SNew(SHorizontalBox);
	InitializeFightHUD();

	ChildSlot
		.VAlign(VAlign_Fill)
		.HAlign(HAlign_Fill)
		[
			SNew(SOverlay)
			+SOverlay::Slot()
			.HAlign(HAlign_Left)
			.VAlign(VAlign_Center)
			[
				SNew(SVerticalBox)
				+ SVerticalBox::Slot()
				[
					SNew(SButton)
					.Text(FText::FromString("Blue Team!!"))
					.OnClicked(this, &SDB_XWidget::HUDDefaultBehaviour, EHUDState::HUD_Construct)
					.DesiredSizeScale(FVector2D(2, 2))
				]
			]
			+ SOverlay::Slot()
				.HAlign(HAlign_Right)
				.VAlign(VAlign_Center)
				[
					SNew(SVerticalBox)
					+ SVerticalBox::Slot()
					[
						SNew(SButton)
						.Text(FText::FromString("Red Team!!"))
						.OnClicked(this, &SDB_XWidget::HUDDefaultBehaviour, EHUDState::HUD_Basic)
						.DesiredSizeScale(FVector2D(2, 2))
					]
				]
				
		];`,

Method that gets called on clicked

FReply SDB_XWidget::HUDDefaultBehaviour(EHUDState NewHUDState)
{
	switch (NewHUDState)
	{
	case EHUDState::HUD_Basic:
		CurrentPlayerController->OwnTeam = EPlayerTurn::T_P1;
		GEngine->GameViewport->AddViewportWidgetContent(FightContainer.ToSharedRef());
		break;
	case EHUDState::HUD_Construct:
		CurrentPlayerController->OwnTeam = EPlayerTurn::T_P2;
		GEngine->GameViewport->AddViewportWidgetContent(ConstructContainer.ToSharedRef());
		break;
	}
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Button Clicked!"));
	return FReply::Handled();
}

None of this method is Server / Client only, or anything like that. I believe that may be the issue but I don´t quite understand why since this is a particular thing that only the client should care about.

Can anybody help me with this?

Thanks!

Forgot to mention

Im running a dedicated server with two clients.

I havent start replicating anything at all. which means, this HUD functions are not been replicated in any case and no variables are been replicated either. (Which for me it doesn’t make sense to be replciated since each hud is completely independent and particular of a specific client/player?)

Thanks!

The only thing I can think of is that this call " GEngine->GameViewport->AddViewportWidgetContent(ConstructContainer.ToSharedRef());" adds the widget to a default viewport…or maybe player 0 viewport only… so I must get the viewport from somewhere else…maybe from the own player controller itself… but I dont know if Im just saying stupid things…or that makes sense… or if I can access to the viewport from the controller and then add the content…