How do I get a button on a startmenu to load a level in Javascript?

Hey there,
I’m still fairly new to Unity and I’ve been messing around in Javascript, trying to get a button on a GUI startmenu to load a level.

I’ve tried

if (GUI.Button.enabled = true (Application.LoadLevel ("cannonball")));

But I get one error;
Assets/Start Menu/Button.js(6,24): BCE0044: expecting ), found =.

I am using MonoDevelop for Unity, and Unity keeps telling MonoDevelop that the 6,24 error is right next to the =

Am I doing something horribly wrong or no?

lol

Try to look at the examples in the help/scripting Reference/runtime classes/GUI .

Also help/scripting Reference/runtime classes/ application .

You should make use of the free tutorials/demos
in the resources section here on this site.

I’ve been looking at those and they offer little help with the particular error that I have.

Does Something like this example work for what you need.
:slight_smile:

function OnGUI() {

    if(GUI.Button(Rect(10,10,50,50),"Load Level")) {
      Application.LoadLevel ("Your Level Name");
    }

}

Fantastic! It works!

Thank you :slight_smile: