- Home /
Unexpected Token:.. while following a tutorial.
Hello all, Im new to scripting so I'm following a tutorial however I get the following error: "SideTrigger.js(7,30): BCE0043: Unexpected token: .." The tutorial I'm following is for an older version of Unity (I have 4.3 and I think the tutorial is for 3.x). I've read that the JS component of Unity has changed a bit since 3.x, so I'm guessing that's why I get the error but I can't seem to figure out a solution.
The error is for the line: var dievalueComponent.currentValue=faceValue;
Below is the full script:
#pragma strict
public var faceValue = 0;
function OnTriggerEnter(other : Collider){
var dieGameObject=GameObject.Find("SixSidedDie");
var dieValueComponent=dieGameObject.GetComponent("DieValue");
var dievalueComponent.currentValue=faceValue;
Debug.Log(faceValue);
}
function Update () {
}
Answer by robertbu · Dec 07, 2013 at 03:27 PM
This code would also have trouble in 3.x. The problem is line 7. It should be:
dieValueComponent.currentValue=faceValue;
First you need to not use 'var'. Second the spelling and case must batch the variable you declared in the previous line.
Thanks for the reply :)
Now I get the error: /SideTrigger.js(7,27): BCE0019: 'currentValue' is not a member of 'UnityEngine.Component'. :(
Don't use quotes inside GetComponent(). By using a type, Unity knows the type of the component you are acquiring:
var dieValueComponent=dieGameObject.GetComponent(DieValue);
Your answer
![](https://koobas.hobune.stream/wayback/20220613123631im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unexpected Token: if 2 Answers
Unexpected Token 3 Answers
Help me with this Unexpected token error 1 Answer
Unexpected token: if 1 Answer
Unxepected token: Var (Please Help) 1 Answer