How to make an object dissapear when I pick up an item, then reappear when dropped?

In my game, the character is holding a flashlight by default. To make the flashlight shine, I am using a spotlight. I would like to know how to disable both of these (make them invisible) when I pick up another object. Then when I drop/release the picked up object, they will reappear again. Please help! If you want more detail, ask me. Also I use JavaScript.

I would use Destroy(gameObject) when picking up the object, and then instantiate an identical object when you want to “drop” it. If you know what I mean?

Instantiate: Unity - Scripting API: Object.Instantiate
Destroy: Unity - Scripting API: Object.Destroy

Hope it helps!

EDIT: I just read all of the post, and in your particular instance, I guess you could turn off the mesh renderer for the flashlight, when you want to hide it? and then just disable the spotlight?
You could always make a fancy animaiton that, like, shows that you put the flashlight away, and then turn off the mesh renderer of something. xD

I guess this method is kinda cheap, but it will work.

Thankyou! As I am new to coding, do you think you could give me a bit of guidance? Like how to write it? thanks

you don’t have to destroy the object and recreate it, just disable it: Unity - Scripting API: GameObject.SetActive

Do you think you could give me an example of this? Like how to write it?