Code feedback.

I am starting to learn networking/multiplayer, i look at the shooter example and online examples to learn replication, But my code is different it still works but i want to know if there is a better way of achieving the same outcome. Im trying to learn and keep my code as short as it needs to be. I feel like there is a lot more code than needed for a simple crouch system.



	void Player_Crouch();
	void Player_UnCrouch();

	UFUNCTION(Reliable, Server, WithValidation)
	void Client_Crouch();
	void Client_Crouch_Implementation();
	bool Client_Crouch_Validate();

	UFUNCTION(Reliable, Server, WithValidation)
	void Client_UnCrouch();
	void Client_UnCrouch_Implementation();
	bool Client_UnCrouch_Validate();





void ALowPolyFPSCharacter::Player_Crouch()
{
	Client_Crouch();
}

void ALowPolyFPSCharacter::Client_Crouch_Implementation()
{
	if (Role == ROLE_Authority) {
		bIsCrouching = true;
		GetCharacterMovement()->MaxWalkSpeed = 300;
		Crouch();
	}
}

bool ALowPolyFPSCharacter::Client_Crouch_Validate()
{
	return true;
}

void ALowPolyFPSCharacter::Player_UnCrouch() {
	Client_UnCrouch();
}

void ALowPolyFPSCharacter::Client_UnCrouch_Implementation()
{
	bIsCrouching = false;
	GetCharacterMovement()->MaxWalkSpeed = 600;
	UnCrouch();
}

bool ALowPolyFPSCharacter::Client_UnCrouch_Validate()
{
	return true;
}


Also can someone explain when i should use these two piece of code.
Role < ROLE_Authority
Role == ROLE_Authority

There are always multiple ways to achieve the same outcome. Here is an excellent networking guide http://cedric-neukirchen.net/2017/02/14/multiplayer-network-compendium/ which will also answer your second question