[Closed]Send health to player targeted on item use, C#, online

Im trying to use a potion and have my target heal but when i use my potion the players do not heal, the debug.log’s are called though… so i dont know whats wrong with my code.


//!!!this works!!!//

if (networkView.isMine)
			if (Input.GetKeyDown(KeyCode.F)){
				playerHp = playerHp + 1;
if (target && Input.GetKey (KeyCode.Mouse0) && target.tag == "Entity" && attackTimer <= Time.time && target != this.gameObject){
				if (networkView.isMine){
					target.networkView.RPC("TakeDamage", RPCMode.All, 1);
				attackTimer = Time.time + 0.4f;



//!!This does not work!!//

[RPC]public void TakeHeal(int value){
		playerScript.playerHp = playerScript.playerHp + value;
		playerScript.playerHp = Mathf.Clamp (playerHp,0,playerMaxHp);
		Debug.Log ("takeheal reached");

the addition never gets called/is not updating/or is not remaining updated long enough for me to see it. but the debug “takeheal reached” works. so TakeHeal() is being called for sure. question is, why does it not update the playerHp?

heres the script i use to call TakeHeal():

void useItem(int mySlot){
		if(contents[mySlot] == potion){
			Debug.Log ("worked");
			if(contents.Count <= 49){
				contents.Add (hiPotion);
				Debug.Log ("added pot");

this is in the inventory script, its debugs are also called, yet once again the other things dont happen, but it does happen if i play single player. im trying to make it work online also. if i play online, i see the debugs but the hipotion never gets added to my List named “contents”. this function DOES however reach the TakeHeal function of my player script, because the debugs all go off properly… any suggestions?

my player is the same prefab for all players, yet each one works on networkView and works flawlessly except for this attempt to “send” my useitem function between scripts. ive made sure that my target was my own player prefab with a debug, and im definately targeting the correct object…

Try adding a Debug.log of the values in the function too to make sure that the value 100 is being passed as value. and player health before and after the addition to see if it’s adding properly.