Instantiate health bar with networking

When a bullet hit an asteroid, the health bar decrease of 10 if the player is only local, so how Instantiate the healthbar on the server, this is my scripts :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class AsteroidController025 : NetworkBehaviour
{

[SerializeField]
private StatA asteroidHealth025;



private void Awake()
{

    asteroidHealth025.Initialize();

}

void OnTriggerEnter2D(Collider2D other)
{
    if (other.gameObject.tag == "Bullet")
    {
        
        asteroidHealth025.CurrentVal -= 10;
        Destroy(other.gameObject);
    }

}

// Use this for initialization
void Start()
{

}

// Update is called once per frame
void Update()
{
    if (asteroidHealth025.CurrentVal <= 0)
    {
        Destroy(this.gameObject);
    }
}

}
and

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

[Serializable]
public class StatA
{
[SerializeField]
private ABarScript aze;

[SerializeField]
private float maxVal;

[SerializeField]
private float currentVal;

public float CurrentVal
{
    get
    {
        return currentVal;
    }

    set
    {

        this.currentVal = Mathf.Clamp(value, 0, MaxVal);
        aze.Value = currentVal;
    }
}

public float MaxVal
{
    get
    {
        return maxVal;
    }

    set
    {

        this.maxVal = value;
        aze.MaxValue = maxVal;
    }
}
public void Initialize()
{
    this.MaxVal = maxVal;
    this.CurrentVal = currentVal;
}

}

Okay I see what is going on. First I will assume you know how Unity Networking works (How the Sync between player objects work, what is network behavior etc)

  1. To Solve your specific problem, I noticed that your StatA script is not inheriting from Network behavior, which means it cannot run any network specific functionalities in the script itself. A script has to inherit from NetworkBehavior and have a NetworkIdentity component to be spawned in the network as you wanted. If you use NetworkServer.Spawn (called in the server/host), then one instance of the object will be spawned in all the player’s scenes and it will have a NetworkInstanceID attached and other properties like “isLocalPlayer”, “HasAuthority?” etc, however, the ownership of the object belongs to the person who spawned it, in our case it would be server/host.
  2. There are cool Unity Network attributes like [SyncVar] it is used to synchronize variables across its instances in the network, which means if you add [SyncVar] above private float currentVal; it will synchronize its value automatically across all the network players. You must also understand that only the player who spawned the Object can control or change its Values (Look more into Object Authority/ who has the right to modify values)

Unity Networking is fun and time consuming at the same time. I kept going back to read networking documentation so often to understand how Command/RPC/ Local Authority/ Synchronization of variables using SyncVar, SyncEvent and how all of that works.

I hope my explanation gives a good start for your problem.