How To Make A Flash Light Turn On Only If It Has A Battery In It?

Am working on a 2d platformer and need to know how to prevent a flash light from turning on if the player doesn’t have a battery. The battery will be a pickup that you will walk on to get.

You can make flash light as gameobject. Then in players script:
public GameObject flashLight; put light in the field.

Then you will need one variable, wich shows the light state. It is depended on your game (boolean for have/doesn’t have, or float for charge full - empty).

Later you can check this variable (if (charge <0)) and enable/disable your flashLight gameobject with
flashLight.SetActive(false); or flashLight.SetActive(true);