#pragma strict
// Variables
var Bal : int = 0;
var CostOfStarter : int = 0;
var StarterObject1 : GameObject;
var StarterObject2 : GameObject;
var StarterObject3 : GameObject;
var ScienceBall1 : GameObject;
var ScienceBall1Add : int = 25;
var StarterButton : GameObject;
var ScienceBall2Teir1 : GameObject;
var CostOfDouble1 : int = 300;
var ButtonDouble1 : GameObject;
var ClickerAmount : int = 1;
var Plank1 : GameObject;
var Plank2 : GameObject;
var Plank3 : GameObject;
var Tester : GameObject;
var TesterUpgrade : GameObject;
var UpgradedClicker1 : GameObject;
var ClickerButton1 : GameObject;
// Make every purchasable game object disabled
function Start(){
StarterObject1.SetActive(false);
StarterObject2.SetActive(false);
StarterObject3.SetActive(false);
ScienceBall1.SetActive(false);
ScienceBall2Teir1.SetActive(false);
ButtonDouble1.SetActive(false);
Plank1.SetActive(false);
Plank2.SetActive(false);
Plank3.SetActive(false);
Tester.SetActive(false);
UpgradedClicker1.SetActive(false);
TesterUpgrade.SetActive(true);
ClickerButton1.SetActive(true);
}
function Update(){
if (Bal > 0)
}
function Clicker() {
Bal += ClickerAmount;
audio.Play();
}
// Only for starter tech
function PurchaseStarter() {
Debug.Log("PurchaseStarter function works");
if (CostOfStarter <= Bal)
{
BuyStarter();
}
}
// Spawn in everything for StarterTech
function BuyStarter() {
StarterObject1.SetActive(true);
StarterObject2.SetActive(true);
StarterObject3.SetActive(true);
ScienceBall1.SetActive(true);
StarterButton.SetActive(false);
ButtonDouble1.SetActive(true);
}
function AddTeir1(Add: int) {
Bal += ScienceBall1Add;
Debug.Log("Phase 3 works");
}
// Display score
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), "Science: "+ Bal);
}
//Only for DoubleSpeed
function PurchaseDouble1(){
Debug.Log("PurchaseDouble1 Works");
if (CostOfDouble1 <= Bal)
{
BuyDouble1();
Bal -= CostOfDouble1;
}
}
// Spawn in everything for Double1 button
function BuyDouble1(){
ScienceBall2Teir1.SetActive(true);
ButtonDouble1.SetActive(false);
Plank1.SetActive(true);
Plank2.SetActive(true);
Plank3.SetActive(true);
}
// Upgrade Clicker1 to Clicker2 (X2 amount needs to be added)
function UpgradeClicker(){
TesterUpgrade.SetActive(false);
ClickerButton1.SetActive(false);
UpgradedClicker1.SetActive(true);
ClickerAmount += 1;
Bal -= 600;
}
OK so I was making a small tycoon type game in unity and I put together this JS and it worked perfectly for a long time. Now I know there are more efficient ways of doing this but I did not come here for that. I was making a menu scene and I had just backed up all my scripts. I accidentally deleted the script folder, so I put the back in. When I did this, the errors showed up, so I deleted scripts until I figured out it was this one causing the problem. Now, I am a beginner to unity an JS in general so I may be overlooking something obvious, and I’m sorry if I am.
Here are the errors:
Assets/Bal.js(43,1): BCE0043: Unexpected token: }.
Assets/Bal.js(44,10): BCE0044: expecting (, found ‘Clicker’.
Assets/Bal.js(44,19): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(49,10): BCE0044: expecting (, found ‘PurchaseStarter’.
Assets/Bal.js(57,10): BCE0044: expecting (, found ‘BuyStarter’.
Assets/Bal.js(57,22): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(66,10): BCE0044: expecting (, found ‘AddTeir1’.
Assets/Bal.js(66,19): BCE0043: Unexpected token: Add.
Assets/Bal.js(66,28): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(71,10): BCE0044: expecting (, found ‘OnGUI’.
Assets/Bal.js(71,18): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(75,10): BCE0044: expecting (, found ‘PurchaseDouble1’.
Assets/Bal.js(75,27): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(84,10): BCE0044: expecting (, found ‘BuyDouble1’.
Assets/Bal.js(84,22): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(93,10): BCE0044: expecting (, found ‘UpgradeClicker’.
Assets/Bal.js(93,26): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/Bal.js(101,1): BCE0044: expecting }, found ‘’.
Thanks in advance for answers! Oh and here is the code for download if you want a closer look:
1895441–122066–Bal.js (2.34 KB)