My inputs are not working.

I am trying to destroy an object in the editor with the Space keycode but it isn’t working. This is the code I wrote.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class destroy : MonoBehaviour
{
   public GameObject Other; 
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKey(KeyCode.Space))
        {
            Destroy(Other);
        }
    }
}

Are there any issues. Please can someone tell me

Hello.

first, you are using

i recommend to use

Second.

I supose you assigned “Other” variable to the object you want to destroy.

Third. (What version of unity are you using?) "Input . " derives from UnityEngine library, so dont need the

using UnityEngine.InputSystem;

And finally, are you sure the script is active and running? is attache to some active object?

Bye!