- Home /
Question by
Bracket · Nov 26, 2012 at 11:33 PM ·
javascriptflashlightprogramcompiler-error
beginner syntax error
function Update () {
if (input.GetKeyDown(f)) {
if (light.enabled == true)
light.enabled = false;
else
light.enabled = true;
}
}
Comment
my new script still isnt working:
function Update () {
if (Input.Get$$anonymous$$eyDown(f)) { if (light.enabled == true) light.enabled = false; else
light.enabled = true;
}
}
try Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.F)
Answer by flaviusxvii · Nov 26, 2012 at 11:47 PM
Also, if you just want to toggle the value, you can do light.enabled = !light.enabled
Also also.. I'd recommend ALWAYS using brackets with if/else blocks. It saves heartache in the long run.
Your answer
Follow this Question
Related Questions
How do I draw back an inactive item ? 1 Answer
How to create a fluid stream? 1 Answer
simple ball rolling mechanic 0 Answers
Changing material Color using RBG? 3 Answers
Has anyone got a Toggle key script? 3 Answers