Problem with script

I found this script which, supposedly, should help me with my car physics issue. The problem is that I get this error everytime I try to add new sript to my main script

Assets/Scripts/Car Control/PlayerCar_Script.js(61,6): UCE0001: ';' expected. Insert a semicolon at the end.

Here’s the script itself

private void Awake()
{
// _currentRotation is defined elsewhere in the class
_currentRotation = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z);
}

private void LateUpdate()
{
// whenever the car is intended to be going straight we adjust localEulerAngle; if the user steers we do not interfere but adjust the rotation angle to allow for correct further calculation

// _steer is defined elsewhere and
// is taken from the user in FixedUpdate()
// as follows: _steer = Input.GetAxis("Horizontal"); 
if (_steer == 0)
{
float y = _currentRotation.y;
transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
}
else
_currentRotation.y = transform.localEulerAngles.y;
}

The line error message referring to is

float y = _currentRotation.y;

As you can see the is already a semicolon there.

I have very, very limited knowledge in programming, but I have a suspicion that the script is written in C and my main script is written in Java. If this is the issue, could somebody tell me what I need to change to make this script work?

Yes, the above code is indeed C# syntax which is what’s causing the trouble if you are trying to compile it within a Javascript script file :slight_smile: So I’m going to guess you have mixed this script code with a Javascript script file?

For obvious reasons I don’t have the rest of your script, but here is the C# script you provided converted to Javascript which compiles just fine:

#pragma strict

var _currentRotation : Vector3;
var _steer = 1;

function Awake()
{
	// _currentRotation is defined elsewhere in the class
	_currentRotation = Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z);
}

function LateUpdate()
{
	// whenever the car is intended to be going straight we adjust localEulerAngle; if the user steers we do not interfere but adjust the rotation angle to allow for correct further calculation
	
	// _steer is defined elsewhere and
	// is taken from the user in FixedUpdate()
	// as follows: _steer = Input.GetAxis("Horizontal"); 
	if (_steer == 0)
	{
		var y = _currentRotation.y;
		transform.localEulerAngles = Vector3(transform.localEulerAngles.x, y, transform.localEulerAngles.z);
	}
	else
		_currentRotation.y = transform.localEulerAngles.y;
}

Obviously you just delete the temporary variables I created to compile the example which your code comments stated exists elsewhere in the script :slight_smile:

Hopefully it will be of some help to you!