No owning connection for actor. Function will not be processed

Hello. I am new to multiplayer developing and I have a problem with Client. I can’t say to Server that I want to decrease my health. If I’m a host then all works fine, but when I’m a client I get the warning:

.h

	UFUNCTION()
	void TakeDamage(float damage) override;

	UFUNCTION(Server, Reliable, WithValidation)
	void Server_TakeDamage(float damage);

	UFUNCTION()
	void DecreaseHealth(float decrement);

.cpp

void ACustomCharacter::TakeDamage(float damage)
{
	if (Role < ROLE_Authority)
	{
		//Client can't call the function
		Server_TakeDamage(damage);
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Client takeDamage"));
	} else
	{
		//Server works properly
		DecreaseHealth(damage);
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Server takeDamage"));
	}
}

void ACustomCharacter::Server_TakeDamage_Implementation(float damage)
{
	DecreaseHealth(damage);
}

bool ACustomCharacter::Server_TakeDamage_Validate(float damage)
{
	return true;
}

void ACustomCharacter::DecreaseHealth(float decrement)
{
	health -= decrement;
}

What am I doing wrong? Please, help!

I hate to revive an old post, but did you figure this out? Or if not maybe someone can see this and chime in.

See this answer from.

In the function that is calling the server, use IsLocallyControlled() first to check if it’s currently controlled.

I was able to avoid this anoing warning, and keeping work everything as needed, by using:

  • HasAuthority() on scope that should be executed on server
  • IsLocallyControlled() for scope that should be executed on client.
    For now working good. And no more spamming warnings, that make my CPU throttle:)