Only host can attack players

Hi i cant seem to get my clients to attack others.
the target variable dosent get filled adn even when i fill it manually they still dont attack
it works perfectly fine for the host tho

here is my attacking code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
public class Attacking : NetworkBehaviour {
    NavMeshAgent agent;
    public Transform target;
    public int Damage;
    public float attackSpeed = 5;
    public float distance;
    public float attackDistance = 5;
    private float nextDamage;
    // Use this for initialization
    public override void OnStartLocalPlayer()
    {
        agent = GetComponent<NavMeshAgent>();
    }
    private void Start()
    {
        nextDamage = Time.time + attackSpeed;
    }
    // Update is called once per frame
    void FixedUpdate () {
        if (!isLocalPlayer)
        {
            return;
        }
        if (Input.GetMouseButton(0))
        {
            target = null;
        }
            if (Input.GetMouseButton(1))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
                if (hit.collider.gameObject.tag == "enemy" || hit.collider.gameObject.tag == "Player")
                {
                    target = hit.collider.transform;
                }
                   
            }
        }
        if(target != null)
        {
            distance = Vector3.Distance(transform.position, target.position);
            agent.destination = target.position;
            if (distance <= attackDistance)
             {
                agent.isStopped = true;
                agent.ResetPath();
                if (nextDamage <= Time.time)
                {
                    nextDamage = Time.time + attackSpeed;
                    CmdTakeDamage(Damage);
                }
            }
        }
    }
    [Command]
    public void CmdTakeDamage(int amount)
    {
        target.GetComponent<PlayerStats>().RpcTakeDamage(amount);
    }
}

and here is my health script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
public class PlayerStats : NetworkBehaviour {
    public const int maxHealth = 100;
    public Transform spawnpoint;
    [SyncVar]
    public int currentHealth = maxHealth;

    public Slider healthSlider;                            
    public Image damageImage;
    public float flashSpeed = 5f;                             
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f);
    public bool damaged;
    // Use this for initialization
    public override void OnStartLocalPlayer()
    {
        healthSlider = GameObject.Find("HUDCanvas/HealthUI/Slider").GetComponent<Slider>();
        damageImage = GameObject.Find("HUDCanvas/HealthUI/DamageImage").GetComponent<Image>();
        spawnpoint = GameObject.Find("SpawnPoint").transform;
    }

    // Update is called once per frame
    void Update () {
        if (damaged)
        {
            // ... set the colour of the damageImage to the flash colour.
            damageImage.color = flashColour;
        }
        // Otherwise...
        else if (damageImage != null)
        {
            // ... transition the colour back to clear.
            damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
        }
        damaged = false;

        if (Input.GetKeyDown(KeyCode.Space))
        {
            RpcTakeDamage(5);
        }
        healthSlider.value = currentHealth;
    }
    [ClientRpc]
    public void RpcTakeDamage(int amount)
    {
         currentHealth -= amount;
         RpcDamageEffect();
         if (currentHealth <= 0)
         {
             currentHealth = maxHealth;
             RpcRespawn();
         }
    }
   
    void RpcDamageEffect()
    {
        if (isLocalPlayer)
        {
            damaged = true;
        }
    }

    [ClientRpc]
    void RpcRespawn()
    {
        if (isLocalPlayer)
        {
            // move back to zero location
            transform.position = spawnpoint.position;
        }
    }
}

ive tried every combination under the sun of client,target rpc’s comammnds.

the only way i was able to get it to slightly work was remove all of the clientrpc
but then the damage effect and health bar wouldn’t get updated

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
public class Attacking : NetworkBehaviour {
    NavMeshAgent agent;
    public Transform target;
    public int Damage;
    public float attackSpeed = 5;
    public float distance;
    public float attackDistance = 5;
    private float nextDamage;
    // Use this for initialization
    public override void OnStartLocalPlayer()
    {
        agent = GetComponent<NavMeshAgent>();
    }
    private void Start()
    {
        nextDamage = Time.time + attackSpeed;
    }
    // Update is called once per frame
    void FixedUpdate () {
        if (!isLocalPlayer) return;
        if (Input.GetMouseButton(0))
        {
            target = null;
        }
            if (Input.GetMouseButton(1))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
                if (hit.collider.gameObject.tag == "enemy" || hit.collider.gameObject.tag == "Player")
                {
                    target = hit.collider.transform;
                }
                   
            }
        }
        if(target != null)
        {
            distance = Vector3.Distance(transform.position, target.position);
            agent.destination = target.position;
            if (distance <= attackDistance)
             {
                agent.isStopped = true;
                agent.ResetPath();
                if (nextDamage <= Time.time)
                {
                    nextDamage = Time.time + attackSpeed;
                    if (target.GetComponent<PlayerStats>())
                    {
                        target.GetComponent<PlayerStats>().TargetTakeDamage(Damage);
                    }
                    if (target.GetComponent<EnemyStats>())
                    {
                        target.GetComponent<EnemyStats>().TargetTakeDamage(Damage);
                    }
                    Debug.Log("attack sent");
                }
            }
        }
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
public class PlayerStats : NetworkBehaviour {
    public const int maxHealth = 100;
    public Transform spawnpoint;

    [SyncVar(hook = "OnChangeHealth")]
    public int currentHealth = maxHealth;

    public Slider healthSlider;                            
    public Image damageImage;
    public float flashSpeed = 5f;                             
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f);
    public bool damaged;
    // Use this for initialization
    public override void OnStartLocalPlayer()
    {
        healthSlider = GameObject.Find("HUDCanvas/HealthUI/Slider").GetComponent<Slider>();
        damageImage = GameObject.Find("HUDCanvas/HealthUI/DamageImage").GetComponent<Image>();
        spawnpoint = GameObject.Find("SpawnPoint").transform;
    }

    // Update is called once per frame
    void Update () {
        if (!isLocalPlayer) return;
        if (damaged)
        {
            // ... set the colour of the damageImage to the flash colour.
            damageImage.color = flashColour;
        }
        // Otherwise...
        else if (damageImage != null)
        {
            // ... transition the colour back to clear.
            damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
        }
        damaged = false;

        if (Input.GetKeyDown(KeyCode.Space))
        {
            TargetTakeDamage(5);
        }
    }

    public void TargetTakeDamage(int amount)
    {
        Debug.Log("Attack recived");
        currentHealth -= amount;
        RpcDamageEffect();
        if (currentHealth <= 0)
        {
            currentHealth = maxHealth;
            RpcRespawn();
        }
    }
    [ClientRpc]
    void RpcDamageEffect()
    {
        if (isLocalPlayer)
        {
            damaged = true;
        }
    }
    void OnChangeHealth(int currentHealth)
    {
        healthSlider.value = currentHealth;
    }
    [ClientRpc]
    void RpcRespawn()
    {
        if (isLocalPlayer)
        {
            // move back to zero location
            transform.position = spawnpoint.position;
        }
    }
}

ok with my current code the only error i get is

RPC Function RpcDamageEffect called on client.
UnityEngine.Debug:LogError(Object)
PlayerStats:CallRpcDamageEffect()
PlayerStats:TargetTakeDamage(Int32) (at Assets/PlayerStats.cs:52)
Attacking:FixedUpdate() (at Assets/Attacking.cs:56)

similar errors for when the player dies it wont call his re spawn function

how can i get around this?

currentHealth is a SyncVar so you can only modify it on the Server. Just apply the change on the server and the clients will update their variable, you can still Rpc call the damage routine, but there is no need to modify a SyncVar on clients.

fixed it by changing my atacking code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
public class Attacking : NetworkBehaviour {
    NavMeshAgent agent;
    public Transform target;
    public string targetIdentity;
    public int Damage;
    public float attackSpeed = 5;
    public float distance;
    public float attackDistance = 5;
    private float nextDamage;
    // Use this for initialization
    public override void OnStartLocalPlayer()
    {
        agent = GetComponent<NavMeshAgent>();
    }
    private void Start()
    {
        nextDamage = Time.time + attackSpeed;
    }
    // Update is called once per frame
    void FixedUpdate () {
        if (!isLocalPlayer) return;
        if (Input.GetMouseButton(0))
        {
            target = null;
        }
            if (Input.GetMouseButton(1))
        {
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
            {
                if (hit.collider.gameObject.tag == "enemy" || hit.collider.gameObject.tag == "Player")
                {
                    target = hit.collider.transform;
                }
                   
            }
        }
        if(target != null)
        {
            distance = Vector3.Distance(transform.position, target.position);
            agent.destination = target.position;
            if (distance <= attackDistance)
             {
                agent.isStopped = true;
                agent.ResetPath();
                if (nextDamage <= Time.time)
                {
                    nextDamage = Time.time + attackSpeed;
                    if (target.GetComponent<PlayerStats>())
                    {
                        targetIdentity = target.name;
                        CmdWhatWasShot(targetIdentity,Damage);
                    }
                    if (target.GetComponent<EnemyStats>())
                    {
                        targetIdentity = target.name;
                        CmdWhatWasShot(targetIdentity, Damage);
                    }
                }
            }
        }
    }
    [Command]
    void CmdWhatWasShot(string id,int dmg)
    {
        GameObject go = GameObject.Find(id);
        if (go.GetComponent<PlayerStats>())
        {
            go.GetComponent<PlayerStats>().TakeDamage(dmg);
        }
        if (go.GetComponent<EnemyStats>())
        {
            go.GetComponent<EnemyStats>().TakeDamage(dmg);
        }
    }

}