How Do I Make Lights Turn Off and On

I’m trying to make a phone, its working but I want a green light to show when its playing, and a red light to show when its not, it would start red, then when interacted with, it would turn green, then if interacted with again turn red, but if the audio ends, it would turn red.

Interacting Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PhoneController : Interactable
{
    public AudioSource audioSource;
    public bool AudioPlayed = false;
   
    public override void OnFocus()
    {
        print("LOOKING AT " + gameObject.name);
    }

    public override void OnInteract()
    {
        print("INTERACTED WITH " + gameObject.name);
        if(AudioPlayed == false)
        {
            audioSource.Play();
            AudioPlayed = true;
        }

        if(AudioPlayed == true)
        {
            audioSource.mute = !audioSource.mute;
        }
    }

    public override void OnLoseFocus()
    {
        print("STOPPED LOOKING AT " + gameObject.name);
    }

    public void Update()
    {
        if(AudioPlayed == true)
            return;
    }
}

Are you receiving any errors? Does your prints shows up on the console?

No, this is working, but idk how to do the lights

Find out if you’re using this “Interactable” object properly.

I say this because you’re overriding a bunch of methods, but not calling their base methods. This may be acceptable, but I’m not familiar with the system you’re using.

But if it is, it’s also weird that Update() is not also an overrided function that is calling a base, and further your Update() code does absolutely nothing, so unless you intend to do more later in Update(), just delete the entire function.

This is why inheritance is fragile in Unity: most Unity devs never expect Monobehaviour methods to have base-class dependencies and contacts, so there’s no formal “best practices” about it.

I think I figured out how I can do it using update, but how do I tell it which lights I want it to effect, like I did with the audio source

The same way: make either a single Light or an array, drag 'em in.

public Light TheLight;
// or
public Light[] TheLights;