Can't access the script of an instantiated prefab :(

I have this code that works fine:

public class Main : MonoBehaviour {
	
	public Human prefab;
	
	void Start(){		

		Human human = (Human)Instantiate (prefab);	

        }
}

It creates a human that walks around and does what he should. What’s weird is that “Human” is the name of the class, not the prefab. What I’d like to do is alter some properties in this script. But if I try:

human.speed = 5;

…I get a CS1061 error about it not containing definitions. I’ve looked this up on the forums and in the manual, and there seems to be clear answers, but when I implement them it doesn’t work. I think I’m still missing something core here… I tried using getComponent() to get the script, but that doesn’t work either. Any ideas on what I’m missing here? Thanks!

BTW, this is the GetComponent script I tried.

		Human c = human.GetComponent<Human>();
		c.charName = "gabe";

It showed the properties fine as I typed c. but it still did not set the value when I ran it. I’m doing something wrong…

This might be a wrong use of static variables. Do you plan on having many Human objects at the same time? If so, static won’t do as all of them would get the same unique speed.

I thought static meant that it was unchangeable

Nope, this is const or readonly. You could have an issue with naming though. From what I see, you are mixing prefab reference and object reference

Human.cs

public class Human : MonoBehaviour {
    public int speed = 5;
}

TheOtherScript.cs

public class NewClass:MonoBehaviour {
    public GameObject prefab;  // Drag prefab here from editor
    GameObject human;
    void Start(){
        human = (GameObject)Instantiate(prefab, new Vector3(0,0,0), Quaternion.identity);
    }
    void Update(){
        if(Input.GetKeyDown(KeyCode.Space)){
            Human script = human.GetComponent<Human>();
            script.speed=10;
        }
    }
}

Fact is the prefab declaration is a reference to a prefab in the project panel. This is not what you need to access. Also your Human declaration is within the Start, so it gets lost at the end of it. When using human you were talking to the prefab but not the object.
Instantiate returns an Object that you need to cast into a GameObject to have access to the functionality of a game object.

you should Instantiate a GameObeject with a script named “Human” not to Instantiate a script only.