- Home /
The code is giving me errors
The code is giving me errors. I was working fine, then I updated Unity to the latest version and now the script is giving me three errors.
 #pragma strict
 
 var bullitPrefab:Transform;
 
 function Start () {
 
 }
 
 function Update () {
 
  if(Input.GetButtonDown("Fire1"));
 
    {
      
      var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
   
   bullit.rigidbody.AddForce(transform.forward * 3000);   
 
    }
 }
Here are the errors:
- Assets/Bullet.js(15,6): BCE0043: Unexpected token: var. 
- Assets/Bullet.js(15,9): UCE0001: ';' expected. Insert a semicolon at the end. 
- Assets/Bullet.js(15,9): UCE0001: ';' expected. Insert a semicolon at the end. 
I have tried to fix the errors. Please help.
Thank you.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by asimov · Jul 19, 2012 at 08:51 PM
You have a semi-colon (;) after the if-statement.
Remove it and it should be fine :)
So the code should be:
 #pragma strict
 
 var bullitPrefab : Transform;
 
 function Start () 
 {
 
 }
 
 function Update () 
 {
     if(Input.GetButtonDown("Fire1")) // Removed - ;
     {
         var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity);
 
         bullit.rigidbody.AddForce(transform.forward * 3000);   
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
Bullet Script 2 Answers
one bullet at a time 1 Answer
Issues with bullet not subtracting properly 1 Answer
bullets don't go forward 1 Answer
SCRIPT NOT WORKING 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                