can someone Repair Manual GetComponent Please

in GetComponent

I found this thread in 3 hours searching through all Q/A about accessing the variable in other scripts

it will not only help new players it’ll help me too as I’ll propably forgot about it and want to search for it in future

and please don’t say to people on most frequently asked questions to RTFM because maybe the man doesn’t describe that problem correctly

if someone has better example of code please share it to help our wiki

please add the code

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    public OtherScript sscript;
    public GameObject ObjectWithScript;
    void Start() {
        sscript someScript;
        ObjectWithScript = GameObject.Find("Player");
        sscript = ObjectWithScript.GetComponent("OtherScript") as OtherScript;
    }
    void Example() {
        Debug.Log (OtherScript.x);
    }
}

using UnityEngine;
using System.Collections;


public class OtherScript : MonoBehaviour {
       public int x = 10;

The manual has great examples of accessing other components - clearly the documentation for GameObject.GetComponent isn’t really the right place for it so they put it here. There are additional tutorials and docs available for GetComponent on Unity Gems