title: SyncVar not working Unity Networking
body: <p>The [SyncVar] attribute is not working for me in my game. I have made sure that:</p>
  
  <ol>
  <li>I changed the variable with a command function</li>
  <li>I correctly added the syncvar attribute and the hook</li>
  <li>The client can update the variables on the server, but the server is not updating the variable on the client</li>
  </ol>
  
  <p>Here are my scripts: </p>
  
  <p>Player Shooting Script:</p>
  
  <pre><code>using UnityEngine;
  
  using System.Collections;
  
  using UnityEngine.Networking;
  
  public class PlayerShoot : NetworkBehaviour {
  
  public GameObject shootPosition;
  
  public float shootRange = 100;
  public float shootRate = 0.2f;
  float nextCheck;
  
  public int damage = 10;
  
  // Use this for initialization
  void Start () {
  
  }
  
  void DetectShooting(){
      if (Time.time &gt; nextCheck &amp;&amp; Input.GetMouseButton(0)) {
          nextCheck = Time.time + shootRate;
          CmdShoot ();
      }
  
  }
  
  [Command]
  void CmdShoot(){
      RaycastHit hit;
      Ray bulletDirection = new Ray (shootPosition.transform.position, transform.forward * shootRange);
      Debug.DrawRay (shootPosition.transform.position, transform.forward * shootRange, Color.blue, 10.0f);
      if (Physics.Raycast (bulletDirection, out hit, 100)) {
          print (hit.transform.name);
  
          if (hit.transform.CompareTag ("Player")) {
              hit.transform.GetComponent&lt;PlayerHealth&gt; ().DeductHealth (damage);
  
          }
  
      }
  }
  
  // Update is called once per frame
  void Update () {
      print (isLocalPlayer);
      if (isLocalPlayer)
      DetectShooting ();
  }
  }
  </code></pre>
  
  <p>Player Health Script:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  using UnityEngine.Networking;
  
   public class PlayerHealth : NetworkBehaviour {
  
  
  public static int maxHealth = 100;
  
  [SyncVar (hook ="UpdateUI")]
  public int currentHealth = maxHealth;
  
  public Slider healthBar;
  
  void UpdateUI(int hp){
      healthBar.value = currentHealth;
  }
  
  public void DeductHealth(int damage){
      if (isServer)
      currentHealth -= damage;
  
  }
  
  // Use this for initialization
  void Start () {
      //InvokeRepeating ("DeductHealth", 0, 2);
      SetInitialReferences ();
  }
  
  void SetInitialReferences(){
  
  
  }
  
  // Update is called once per frame
  void Update () {
  
  }
  }
  </code></pre>
  
  <p>Here are some Screen Shots:</p>
  
  <p><a href="https://i.stack.imgur.com/yHB0h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHB0h.jpg" alt="Client Screen Shot After shooting the host"></a></p>
  
  <p><a href="https://i.stack.imgur.com/xi5AP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xi5AP.png" alt="Host Screen Shot After being shot"></a></p>