How to access the light component on a camera object?

I have my scene set up with a camera called Main Camera. Attached is a Light component set to a spotlight and the camera is within an FPS controller. This is perfect because it lets the FPS controller handle the flashlight rotation automatically.

What I’m trying to do is toggle the intensity of the light with code based on whether the player has collected the flashlight object in-game or not (toggle on/off).

I’m having trouble figuring out how to access the light component of the camera.

Any help would be appreciated!
Our team is working in Javascript for this project. :slight_smile:

So if it is “on” the main camera then:

    Camera.main.light.enabled = true;

If it is on the camera or in the child chain of the main camera:

    Camera.main.GetComponentInChildren(Light).enabled = true;