2 scripts working at home but giving errors at uni on different Unity version

So at home I have 2 slowmotion scripts that work perfectly with no errors and at home I have unity version 4.3.3

So I tried opening my project at uni which has the older version of Unity, version 4.2.1f4

and before it said I could risk data loss and after importing it I got hundreds of errors that are cleared after I press clear except for these 2 scripts that give me these errors

Why is this happening?

Assets/Scripts/SlowMotion.js(30,2): UCE0001: ‘;’ expected. Insert a semicolon at the end.

Code for this script

var currentSlowMo : float = 0;
var slowTimeAllowed : float = 2.0;

function Update()
{

   if(Input.GetButtonDown ("Fire2"))
   {

       if(Time.timeScale == 1.0)
       Time.timeScale = 0.3;

   else

       Time.timeScale = 1.0;
       Time.fixedDeltaTime = 0.02 * Time.timeScale;

    }

    if(Time.timeScale == 0.3)
    {
        currentSlowMo += Time.deltaTime;
    }

    if(currentSlowMo > slowTimeAllowed)
    {
        currentSlowMo = 0;
        Time.timeScale = 1.0;
    {
}

}

}

2nd error

Assets/Scripts/SlowMoTrigger.js(39,2): UCE0001: ‘;’ expected. Insert a semicolon at the end.

var currentSlowMo : float = 0;
var slowTimeAllowed : float = 2.0;
var b : boolean = false;


function OnTriggerEnter (player : Collider) {
if(player.tag=="Player")
b = true;

}

function Update()
{

   if(b == true)
   {

       if(Time.timeScale == 1.0)
       Time.timeScale = 0.3;

   else

       Time.timeScale = 1.0;
       Time.fixedDeltaTime = 0.02 * Time.timeScale;

    }

    if(Time.timeScale == 0.3)
    {
        currentSlowMo += Time.deltaTime;
    }

    if(currentSlowMo > slowTimeAllowed)
    {
        currentSlowMo = 0;
        Time.timeScale = 1.0;
        b = false;
    {
}

}

}

I just don’t understand why it’s working at home but not at uni, but after I imported my file from home at uni with the risk of data loss I also got these errors which are cleared after pressing clear.

typeTree.m_Children.front ().m_Type != SerializeTraits::GetTypeString (NULL)
UnityEditor.DockArea:OnGUI()

Version Control: Unknown version control plugin: Hidden Meta Files

Anybody? Would the best solution just be to contact my uni technicians to upgrade Unity to the version I am using at home which gives me no errors on the scripts above.

It’s really strange though…

For every { there needs to be exactly one }. In both scripts, get rid of the last two }.

look at line 29 SlowMotion.js
and 38 SlowMoTrigger.js

you have { floating around

you will need to delete it and 1 of the following }

All your troubles will melt away…

Thank you Dantus I will try it now and let you know!!!

But why does it work at home for me without giving the same errors I get at uni? Now I’m kind of scared omg

It’s still giving me errors on the same lines I tried deleting the last 2 } and the script error doesn’t update still gives an error to the same line.

I also tried deleting one of each { } still nothing ):

Why does it work at home but not here

Quick tips:

Here is your script in an intuitively readable form:

var currentSlowMo : float = 0;
var slowTimeAllowed : float = 2.0;
 
function Update()
{
	if(Input.GetButtonDown ("Fire2"))
	{
		if (Time.timeScale == 1.0)
		{
			Time.timeScale = 0.3;
		}
		else
 		{
			Time.timeScale = 1.0;
			Time.fixedDeltaTime = 0.02 * Time.timeScale;
		} 
	}
 
	if (Time.timeScale == 0.3)
	{
		currentSlowMo += Time.deltaTime;
	}
 
	if(currentSlowMo > slowTimeAllowed)
	{
		currentSlowMo = 0;
		Time.timeScale = 1.0;
	{
}

You should have a close look at lines 8 to 16, because I am not sure if that is you actual intention.

I went through them checking all {}

This is with Unity Version 3.5.7f6 there are no errors reported:

SlowMoTrigger.js

var currentSlowMo : float = 0;
var slowTimeAllowed : float = 2.0;
var b : boolean = false;

function OnTriggerEnter (player : Collider)
{
	if(player.tag=="Player")
    b = true;
}

function Update()
{
	if(b == true)
	{
		if(Time.timeScale == 1.0)
		{
			Time.timeScale = 0.3;
		}
		
		else
		{
			Time.timeScale = 1.0;
			Time.fixedDeltaTime = 0.02 * Time.timeScale;
		}
		
		if(Time.timeScale == 0.3)
        {
            currentSlowMo += Time.deltaTime;
        }
        
        if(currentSlowMo > slowTimeAllowed)
        {
        	currentSlowMo = 0;
            Time.timeScale = 1.0;
            b = false;
        }
  	}
}

SlowMotion.js

var currentSlowMo : float = 0;
var slowTimeAllowed : float = 2.0;
function Update()
{
	if(Input.GetButtonDown ("Fire2"))
	{
		if(Time.timeScale == 1.0)
		Time.timeScale = 0.3;
	}
	else
	{
		Time.timeScale = 1.0;
		Time.fixedDeltaTime = 0.02 * Time.timeScale;
	}
	
	if(Time.timeScale == 0.3)
	{
		currentSlowMo += Time.deltaTime;
	}
	
	if(currentSlowMo > slowTimeAllowed)
	{
		currentSlowMo = 0;
		Time.timeScale = 1.0;
	}
}

Try them

Than you very much Dantus and Softwizz works for now :wink:

really appreciate it

But why were the original scripts working from unity at home???

Does scripting change for every Unity Version

No it doesn’t. I assume that the scripts are not 100% identical.

But I never changed the script, I saved it at home and opened/imported it at uni

However before I improted my project it said I could lose data and everything and I did get some data loss error messages???

thanks so much again

That message usually appears when you open an existing Unity project with an older version.
Just check your scripts at home. If they work there, they will work elsewhere too.