- Home /
How to finish my else if statement?
i want to add an else statement at the end of my script but i'm kind of dooped on how to put it in and make it say false. it just comes up with expecting EOF
. var enabled : boolean;
function Start () {
}
function Update () {
if (Input.GetButtonDown("Aim"))
GetComponent(ThirdPersonController).enabled = false;
print("True");
} else {print("False"); )
Answer by mmacdonaldscp · Jul 15, 2013 at 01:31 AM
I believe you have an unmatched { starting with the "else". Try this:
function Update () {
if (Input.GetButtonDown("Aim"))
{
GetComponent(ThirdPersonController).enabled = false;
print("True");
}
else
{
print("False");
}
Answer by Cerbion_ · Jul 15, 2013 at 01:18 AM
Geez, horrible, next time please make sure you use the the "code block" to make your codelines easier readable.. I just did it instead:
replace your code with this:
#pragma strict
var enabled : boolean;
function Start ()
{
}
function Update ()
{
if (Input.GetButtonDown("Aim"))
{
GetComponent(ThirdPersonController).enabled = false;
print("True");
}
else
{
print("False");
}
}
And here's a little tip: always try to make your sourecode readible for you and others, if you need help but nobody can decypher what you coded, helping you would be really difficult.
That being said, it should work now, oh and BTW "expecting EOF" means nothing less than that the compiler expects that the function (in this case Update()) should End (you were having a ')' instead of a '}' bracket.
EOF = EndOfFunction
I hope I helped you out, have a good day.
oh i'm sorry for some reason when i sent the answer in it came out in the wrong format but this is the exact answer i needed thanks now i can do a lot more with my game
Your answer
Follow this Question
Related Questions
some scripting help 2 Answers
My backpack script doubt 0 Answers
If \ Else how does the program reads it? 2 Answers
if else statement doesnt work 1 Answer
A single else statement for multiple if statements 2 Answers