Reputation: 41
I recently started making a new game and I'm kinda an amateur coder.
var FlashlightOn : boolean = true;
function Update () {
ButtonClicket();
}
function ButtonClicket () {
if (Input.GetButton("Flashlight")) && FlashlightOn == true {
Destroy(Flahslight);
FlashlightOn = false;
}
else
{
Instantiate (Flashlight, Vector3(i * 0, 0, 0), Quaternion.identity);
FlashlightOn = true;
}
}
In the compiler error part it says I need to put brackets at the end and some other junk that doesn't need to be done. What am I doing wrong here?
Upvotes: 1
Views: 83
Reputation: 1573
Having run the code through the compiler myself, the errors it's giving are valid. Your code simply has a syntax problem and a typo:
if (Input.GetButton("Flashlight") && FlashlightOn == true) {
The close parenthesis for the if statement was in the wrong place.
Destroy(Flashlight);
You misspelled 'Flashlight'.
Also, i
isn't defined isn't this code snippet, which is fine if it's a global variable, but you may want to double check it.
Upvotes: 2