How to make script for FlashLight Sound , ON and OFF.

Hello i make a FlashLight for my FPS and a FlashLight script , and its work good , but i dk how to make a script for a sound of FlashLight when i turn it off and on , do i make one more script or do i put it on this script i made beafore . thanks .

Everything that is separate from anything else (scripts that wont be on several objects) is more convenient to keep in one place. I would say all functions and caching etc. that is directly connected to your flashlight is easiest to keep in your flashlight script.

Here’s a sample script to handle audio while turning on/off,

private var lightSource : Light;
var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;

function Start () {
	lightSource = GetComponent(Light);

function Update () {
	if (Input.GetKeyDown(KeyCode.F)) ToggleFlashLight();

function ToggleFlashLight () {

	if (lightSource.enabled) {
		audio.clip = soundTurnOn;
	} else {
		audio.clip = soundTurnOff;

@script RequireComponent(AudioSource)

Thanks i will try it , and i will let u know did it work .