GUI.Button toggling object visibility.

Hello, I am trying to make it so that a GUI button controls an objects visibility.

var icon : Texture2D;
var toggleBool = true;
var target : GameObject;
 
function OnGUI () {
    GUI.Box (Rect (0,0,100,90), "Top-left");
    toggleBool = GUI.Button (Rect (10,30,90,20), toggleBool, "turn on/off");
    target.renderer.enabled = toggleBool; 
}

However I am getting the following error:

**No appropriate version of 'UnityEngine.GUI.Button' for the argument list '(UnityEngine.Rect, boolean, String)' was found.**

Any idea of the issue or a fix?

I can help you with C# code, not really with javascript…

Here’s the code:

public GameObject target;

void OnGUI()
{
   if (GUI.Button(new Rect(0,0,100,90), "Turn On/Off"))
   {
       target.renderer.enabled = !target.renderer.enabled;
   }
}