- Home /
Question by
LikeShiSui · Nov 25, 2014 at 05:51 AM ·
javascripterror message
Help Needed! expecting (, found 'Chop'.
Yeah, like said above this is the error: BCE0044: expecting (, found 'Chop'.
this is my script:
#pragma strict
var rayLength : int = 10;
var treeScript : TreeController;
var playerAnim : PlayerControl;
function Update()
{
var hit : RaycastHit;
var fwd = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, fwd, hit, rayLength))
{
if(hit.collider.gameObject.tag == "Tree")
{
treeScript = GameObject.Find(hit.collider.gameObject.name).GetComponent(TreeController);
playerAnim = GameObject.Find("Arms05").GetComponent(PlayerControl);
if(Input.GetButtonDown("Fire1"))
{
StopCoroutine("Chop");
StartCoroutine("Chop");
}
}
function Chop ();
{
yield WaitForSeconds(2);
treeScript.treeHealth -= 1;
}
}
}
It's probably sometime quite simple, but please tell me what I am doing wrong, or if there are any other errors in the script. Thanks!
Comment
Best Answer
Answer by HarshadK · Nov 25, 2014 at 05:53 AM
It is in fact quite simple. You have misplaced braces ( { , } ) in your code.
#pragma strict
var rayLength : int = 10;
var treeScript : TreeController;
var playerAnim : PlayerControl;
function Update()
{
var hit : RaycastHit;
var fwd = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, fwd, hit, rayLength))
{
if(hit.collider.gameObject.tag == "Tree")
{
treeScript = GameObject.Find(hit.collider.gameObject.name).GetComponent(TreeController);
playerAnim = GameObject.Find("Arms05").GetComponent(PlayerControl);
if(Input.GetButtonDown("Fire1"))
{
StopCoroutine("Chop");
StartCoroutine("Chop");
}
}
}
}
function Chop ()
{
yield WaitForSeconds(2);
treeScript.treeHealth -= 1;
}
you might want to remove the semicolon at the end of line 27 (line 29 in the 'answer') too ;)
Nice catch. >.<
Guess I was hellbent on looking to solve the exact error and missed on this one ;-)