Item pickup and activating an item afterwards help

Basically im making an indie horror game, and im a beginner to scripting. I want my player to be close to the pickup and itll say “press ‘e’” and i got it all working apart from one thing. My flashlight either stays disabled or stays enabled from the start.
Heres my script so far:

#pragma strict
var player : Transform;
var gui : Transform;
public var target : GameObject;
function Start () {
	gui.guiText.text = ""; = false;


function Update () {
	var dist = Vector3.Distance(player.position, transform.position);
		gui.guiText.text = "Press 'E' To Pick Up The Flashlight";
		gui.guiText.text = "";
	if(Input.GetKeyDown("e") && (dist<2))

I have never done an inventory system before so I might be completely wrong on this, but have you tried using gameObject.SetActiveRecursively instead of gameObject.SetActive ?

i fighured it out now, it turned out I needed

if(Input.GetKeyDown("e") && (dist<2))
	if(Input.GetKeyDown("e") && (dist<2)) = true;