how would one use SyncVar to synchronize an integer value?

Here’s my code:

using UnityEngine;
using UnityEngine.Networking;

public class Player : NetworkBehaviour {
	
	[SerializeField]
	private int maxHealth = 100;

	[SyncVar]
	private int currentHealth;
	
	void Awake ()
	{
		SetDefaults();
	}
	
	public void TakeDamage (int _amount)
	{
		currentHealth -= _amount;
		
		Debug.Log(transform.name + " now has " + currentHealth + " health.");
	}
	
	public void SetDefaults ()
	{
		currentHealth = maxHealth;
	}
}

But when I enter SyncVar as the attribute above the current health, it stays grayed out and has no function.

Read This Documentation : http://docs.unity3d.com/Manual/UNetActions.html

1)First you need to create a function to take damage on Server to client

//[ClientRpc is  command .This will take damage on server to client
     [ClientRpc]
     public void RpcTakeDamageOnServer(int _amount) {
         currentHealth -= _amount ; 
     }

2)Now u need to give command from player to take damage

[Command]
     public void TakeDamage (int _amount)
     {
        Debug.Log(transform.name + " now has " + currentHealth + " health.");
        RpcTakeDamageOnServer(_amount) ;
     }

Now health will sync when u take damage.