What is wrong with this script?

this is a script for fading flashlight. the engine keeps saying “light is not a member of ‘System.Type’”?
what is wrong?
plus, “No appropriate version of ‘UnityEngine.AudioSource.PlayOneShot’ for the argument list ‘(System.Type)’ was found”? i don’t think there is any “javascript grammar” error, but these error message keeps popping out.
what happened? and how do i fix it? some help would be appreciated.

var onClick = AudioClip;
var lightSource = Light;

function Start ()
{
	lightSource.light.enable = false;
	lightSource.light.intensity = 2.85;
}

function Update()
{
	if(lightSource.light.enable == true)
	{
		lightSource.light.intensity -= 0.1 * Time.deltaTime / 5;
		Debug.Log(lightSource.light.intensity);
	}
	
	if(Input.GetKeyDown("f"))
	{
		audio.PlayOneShot(onClick);
		
		if(lightSource.light.enabled == false)
		{
			lightSource.light.enable == true;
		}
		
		else
		{
			lightSource.light.enabled = false;
		}
	}
}

Hey bro, i have a FlashLight script if you want, i don’t know if it’s exactly what you want, but this is what i have :

#pragma strict

var SoundFX : AudioClip;

function Start () {

light.enabled = true;

}

function Update() {
 
if (Input.GetKeyDown("f")) {

audio.clip = SoundFX;

audio.Play();

    if (light.enabled == true)
 
        light.enabled = false;
 
        else
 
        light.enabled = true;
 
    }
 
}

This is a classic JavaScript typing error. Two options to avoid this error

  • Use C#
  • Add #pragma strict to the top of your code

To fix your instance you simply need to type your variables

var onClick : AudioSource;
// and so on...