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 () {
	gameObject.SetActive(true);
	gui.guiText.text = "";
	target.active = false;

}

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

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))
		gameObject.SetActive(false);
	if(Input.GetKeyDown("e") && (dist<2))
		target.active = true;