[Unet] Network Raycast

Hello everyone. I have one question. How to sync raycast? I can sync only client raycast. I have raycast and health scripts. Clients can damage server but client cant damage other clients, and server cant damage clients. Help me please. Oh , I almost forgot about the scripts.
Here they are:

Player

using UnityEngine;
using UnityEngine.Networking;

public class Player : NetworkBehaviour
{
    public float moveSpeed = 3.0f;
    public GameObject bulletPrefab = null; // this prefab will be instantiated on the server

    private Vector3 _velocity;

    // Command means when the client call this function, it's "forwarded" to the server
    // and the code will actually run on server side
    // NOTE: the function name has to start with "Cmd"
    [Command]
    public void Cmd_Shoot()
    {
		RaycastHit hit;
		if (Physics.Raycast (transform.position, transform.forward, out hit, 10000.0f)) {
			if(hit.transform.GetComponent("Health")){
				hit.transform.SendMessage("Cmd_Damage",1);
				Debug.Log("2");
			}
		}
	}

    public override void OnStartLocalPlayer()
    {
        base.OnStartLocalPlayer();

        // you can use this function to do things like create camera, audio listeners, etc.
        // so things which has to be done only for our player
    }

    private void Update()
    {
		// isLocalPlayer is true for the client who "owns" the player object
		// we only want input handling for our player
		if (!base.isLocalPlayer)
			return;

		// handle input here...

		_velocity = Vector3.zero;

		if (Input.GetKey (KeyCode.W))
			++_velocity.z;
		if (Input.GetKey (KeyCode.S))
			--_velocity.z;
		if (Input.GetKey (KeyCode.A))
			--_velocity.x;
		if (Input.GetKey (KeyCode.D))
			++_velocity.x;

		_velocity.Normalize ();

		// when pressing the space button, ask the server to spawn a bullet
		if (Input.GetKeyDown (KeyCode.Space)) {
			Cmd_Shoot ();
	}
}

    private void FixedUpdate()
    {
        // because Local Player Authority is true, the client has to move the player
        // only the resulting transform will be sent to the server and to the other clients
        if (!base.isLocalPlayer)
            return;

        // if that flag is not true, we should check that the code runs only on server
        // it could be done by checking base.isServer

        // transforming and other authoritive stuff here...

        transform.position += _velocity * Time.deltaTime * moveSpeed;
    }
}

Health

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
using UnityEngine.UI;

public class Health : NetworkBehaviour {
	[SyncVar]
	public int hp;
	public Transform UI;

	void Start () {
		hp=100;
	}
	
	void Update () {
		UI.GetComponent<Text> ().text = hp+"";
		if(hp>100){
			hp=100;
		}
		if(hp<0){
			hp=0;
			Death();
		}
	}


	void Death () {
		if (isLocalPlayer) {
			transform.position = new Vector3 (0, 0, 0);	
			hp = 100;
		}
	}

	[Command]
	void Cmd_Damage (int dmg) {
		if (isLocalPlayer) {
		hp-=dmg;
		}
	}
}

Solution: Remove

if (isLocalPlayer) {
         }

from void Cmd_Damage()
Since Command functions are only ran on the server. So hp is only reduced when server is local player.

P.S. You may want to change

if(hit.transform.GetComponent("Health")){
       hit.transform.SendMessage("Cmd_Damage",1);
       Debug.Log("2");
 }

to

if(hit.transform.GetComponent<Health>()){
       hit.transform.GetComponent<Health>().Cmd_Damage(1);
       Debug.Log("2");
 }

For better performance. But do it your way…

I know it is late but it may help people. Here i fixed the code. Syncvar sends server values to clients. So damage calculations must be on the server.

     void Death () {
         if (isServer) {
             transform.position = new Vector3 (0, 0, 0);    
             hp = 100;
         }
     }
 
     [Command]
     void Cmd_Damage (int dmg) {
         if (isServer) {
         hp-=dmg;
         }
     }
 }