Can't make a sprite be disabled

I’m trying to make a black ball become diable/ activate when you press ‘e’ on it’s light.
but it won’t disable at all, nor really come back.


here’s what it looks like

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class light : MonoBehaviour
{
   public GameObject darkness;
    public bool objactiveon = false; 
    bool enter = false;
void start(){
}
//diappear the darkness
  void Update(){
    if (Input.GetKey("e") && enter ){
      Debug.Log("This is a log message.");
             darkness.SetActive(false);}
          }
  // check if playes in the box
void OnTriggerEnter(Collider hit){
      if (hit.CompareTag("Player")){
          Debug.Log("This is a log message.");
         enter = true;
      }}
void OnTriggerExit(Collider hit){
        if (hit.CompareTag("Player")){
           Debug.Log("This is a log message.");
           enter = false;
        }
    }
  }

here’s the code for it
pls give advice

Please use code tags: Using code tags properly

I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

1 Like

Everything @Kurt-Dekker said is true.

That being said, if your text is an actual copy of your code, then it appears your update is not capitalized. update should be Update.

2 Likes

ok, I put the debug logs in and found that update is working and noathing else. I’ll go get pics of the related objects in case there’s something wrong with them
edit; also the bool isn’t working as well

figured it out, I didn’t say it was a 2D collider in the code