AudioClip sound;
if (Input.GetKeyDown("f")) {
light.enabled = !light.enabled;
audio.PlayOneShot(sound);
}
Is not sitting inside your Update funciton for starters, maybe try:
AudioClip sound;
function Update () {
if (Input.GetKeyDown("f")) {
audio.PlayOneShot(sound);
if (light.enabled == true)
light.enabled = false;
else
light.enabled = true;
}
}
If you’re going to play the sound regardless it doesn’t need two if statements just get it to play the sound whenever f is hit. I have no idea what the last if statement is meant to achieve so I’ve left it out as I assume it was just supposed to turn the light on or off which the first statement does.