C# get variable from another script on a seperate object

So I have a simple enough mini game, you shoot by pressing spacebar, a bullet spawns and moves forward, upon hitting something thats not an object tag (ie, a enemy/another player), that target is supposed to lose some health. The game is technically supposed to be online, using Photon Unity Network, and the networking part works, but I cant seem to find a way to actually change the health without Unity complaining about something.

This is the code I am currently using:
(This is OnTriggerEnter for the bullet)

    public GameObject target;
private static int dataHP;
                    target = info.gameObject;
		dataHP = target.GetComponent<NetworkCharacter>().health;
		dataHP-= 10;
		print(target.name + "'s HP left: " + dataHP);

And I get this error:
Static member `NetworkCharacter.health’ cannot be accessed with an instance reference, qualify it with a type name instead

NetworkCharacter is the name of my script, and health is the public static variable of that script, which only exists on the target

So my question is:
How might I be able to basically try and change the variable on the player script that exists on that object, whenever the bullet hits the player?

Thanks for the advice, ill be sure to do that in the future, sorry

  • thanks for the help, it turns out I had the wrong format with another variable on the same script with the static variable - but it did work, thank you.