problem calling a c# function from a script

i’m having an issue with calling a function inside a script the error i get is can’t convert void to float.

what i want do is call a script that returns a floating point value and assign it to a variable inside of a script so i can set it to gui text.

inside my stats script i have

public float getCurrentHealth
get{return health;}

inside my menu script i have:

float health;

health = player.BroadcastMessage("getCurrentHealth");

GUI.Button(new Rect(55, 100, 180, 40), "Health: " + health);

any help would be awesome… I’m just trying to make buttons that have say health: 20/20

BroadcastMessage can never return a value. You should give your menu script a direct reference to the player's health script- either through the inspector with

public PlayerStats stats;

Or by using GetComponent-

PlayerStats stats = player.GetComponent<PlayerStats>();
health = stats.getCurrentHealth();

This is a much faster way of accessing components, as well- you should only use the message system when you can't know exactly what components are going to respond to it (or you don't even know if one will at all).