Hey, I have a Flashlight script:
var lightOfEpicness : Transform;
var clickAudio : AudioClip;
function Start () {
lightOfEpicness.active = false;
}
function Update () {
if(Input.GetKeyUp(KeyCode.F)){
audio.clip = clickAudio;
audio.Play();
if(lightOfEpicness.active == true){
lightOfEpicness.active = false;
} else {
lightOfEpicness.active = true;
}
}
}
and I want it so when I enter a trigger the flashlight goes off.
I tried this but it didn’t work.
var Player : GameObject;
var Script : FlashlightOff = Player.GetComponent(“FlashlightOff”);
function OnTriggerEnter (other : Collider) {
if(other.collider.tag == Player.tag)
{
Script = GetComponent(FlashlightOff);
Script.enabled = false;
}
}