How to use GetComponent?

How would I use GetComponent to change variables in other scripts? I understand the concept behind it, but I cannot setup the script in the right format. I used this (Unity - Scripting API: GameObject.GetComponent)
to set up my script. This is the line of code I am having trouble with:

transform.Find(“box”).GetComponent(lighttoggle).light = true;

In this part of the code, there is a box (gameobject), with a script attached called lighttoggle, With a var (bollean) called light.


But, when I attach the script to the player, the script does not turn on the light. The script works when I attach another trigger to it (Input.GetKeyDown), so the problem is the GetComponent. Can someone tell me how to format the GetComponent so that it will work?


Please don’t ask me if I Googled it, I did.
I will be grateful for any help.
Javascript only, please

-Thanks

lighttoggle shoud be in "s

GameObject.Find(“box”).GetComponent(“lighttoggle”).light(.enabled) = true;

edit: yeah should be GameObject.Find

and you probably want .enabled = true

I think Your first mistake is the fact that you are using transform.Find.

Either use GameOject.Find, or transform.Find(something).gameobject.

And what @gheeler said.