BCE0044 expected (, found *function name*

Hi, so I am kind of new to javascript and to unity. My latest attempt at making an object ended up something like this:

So if I understand correctly, JS objects, unlike in c++, can be initialized using a function that assigns values to this.whatever and can be initialized by doing name = function(). I believe you can call on them by using name.whatever, right?

Well, anyway, here is my object.

function partHullClass(partLoc: Vector3, guiLoc: Rect, number : int){
	this.partLoc = partLoc;
	this.guiLoc = guiLoc;
	this.number = number;
	this.isPartUsed = false;
	this.onGUI = onGUI();
	return this;
}

function onGui(){
if (GUI.Button(Rect(10,70,50,30),"Plus")) {
	if (!isPartUsed) {
		partHullInstance = Instantiate(jaska, partLoc, transform.rotation);
		isPartUsed = true;
		partHullInstance.AddComponent("FixedJoint");
		partHullInstance.GetComponent("FixedJoint").connectedBody = rigidbody;
		partHullInstance.GetComponent("FixedJoint").breakForce = 5;
		partHullInstance.GetComponent("FixedJoint").breakTorque = 5;
	} else {
		Destroy(partHullInstance);
		isPartUsed = false;
}	}

paikka = new Vector3(-3,-3,0.75);
shipHull = new partHullClass(paikka, Rect(10.0,ekatop,koko,koko), 1);
shipHull.onGui();

Sorry about some of the finnish variable names. Also, on the side, I don’t know why I had to use return.this, but it seemed to stop some errors.

But now, every function after it in the code looks like this when I try to compile it:

function Update () {                              Expecting (, found 'update'. (BCE0044)
if (Input.GetKey("w")){                    (on same line) ; expected, insert semicolon...
rigidbody.AddRelativeForce (0, 5, 0);
}

if (Input.GetKey("a")){
rigidbody.AddTorque (0, 0, 5);
}

if (Input.GetKey("s")){
rigidbody.AddRelativeForce (0, -5, 0);
}

if (Input.GetKey("d")){
rigidbody.AddTorque (0, 0, -5);
}	}

Can anyone explain this?

Disclaimer: I know it is probably an obvious mistake, but I am new to JS so have mercy.

I don’t see a closing ‘}’ for the onGui.

You don’t need to call onGui.

OnGUI is called automatically by unity.

You just need to make sure it’s spelled correctly - ‘OnGUI’ not ‘onGui’.

Also, you seem to be missing a lot of the basic code structure.

Unless you didn’t post it all, in that case, please post more of the code.

I’m personally not working with Js, but theses are just some of the things I noticed.

Edit (more stuff I noticed)

You called your first function a class, which is confusing… are you trying to create a class or a function?