NGUI Health SendMessage Has No Receiver (501963)

Hi, I’m trying to make a very simple way to pass the health of the player to ngui as a float and adjust the hp bar. The health of the player seems to work, as does adding a float manually to ngui changes the size of the life bar but I can’t seem to figure out how to connect the two to check on its own.

I have this script PlayerHealth.cs

using UnityEngine; 
using System.Collections;

public class PlayerHealth : MonoBehaviour {
 
 private int maxHealth = 300;
 public int health;
 
 // Use this for initialization
 void Start () {
 health = maxHealth;
 }
 
 // Update is called once per frame
 void Update () {
 gameObject.SendMessage("AlterHealth", .5f);
 }
}

And I have this as VitalBarBasic.cs

using UnityEngine;
using System.Collections;

public class VitalBarBasic : MonoBehaviour {
 private UISlider _slider;
 private float _maxWidth;
 private float _health;
 
 void Awake() {
 _slider = GetComponent<UISlider>();
 _maxWidth = _slider.foreground.localScale.x;
  }
 
 void Start() {   
 }   
 public void Update() {  
 _slider.sliderValue = _health;
 }
 
 public void UpdateDisplay( float x ) {
 _slider.sliderValue = x;   
 }
 
 public void AlterHealth(int newHealth){
 _health = newHealth;
 }
 
}

I don’t think I have the script actually looking in the right place but I’m a little confused how to structure the “sendmessage” Thanks for any help.

I honestly cannot be sure without knowing which gameobject both of your scripts are attached too, but I’m going to assume they are attached to the same gameobject Try removing gameObject.SendMessage(“AlterHealth” .5f) and replacing it with SendMessage(“AlterHealth”, .5f"). Honestly, I don’t know if it will have any affect, but hopefully.

I’m a little confused about the “gameObject” part. I’ve attacked everything under the same game object and it didn’t seem to change anything.
Also, I removed the “gameObject.” and it still says it has no receiver. I’ve also tried BroadcastMessage

all i know is i have had no choice using the ngui system, its to save like 2 hours they say on a hud yet, i know i’m still new to programing yet i can get something in unitys gui system to work 30 seconds and in ngui it takes 5-6 days for samething i wouldnt even use ngui if i didnt have to for my internship