Why won't this work? I'm new and this was for fun; way out of my knowing

using UnityEngine;
using System.Collections;

public class player : MonoBehaviour {

GameObject sphere;

// Use this for initialization
void Start () {

	transform.position = new Vector3 (0, 0, 0);

}

// Update is called once per frame
void Update () {

	 

	if(Input.anyKeyDown){

		GameObject.Instantiate(sphere, new Vector3(2,1,0),  transform.rotation);
		rigidbody.AddForce(new Vector3(100,0,0));

	}

}

}

Well for starters does your object have a rigidbody attached? Tell me what doesn’t work. From your code it seems like you have a variable named sphere and it is of type GameObject. When you press any key a sphere GameObject will instantiate at 2,1,0. the next line says rigidbody.addforce and that will add force to whatever item this script is attached to. If you want the sphere GameObject to move you’r going to need to ad a rigidbody to it, either by code or through the inspector. Also I’m not entirely sure about c# but the first line you have that says GameObject sphere, shouldn’t that have var before it so that it’s a variable.

using UnityEngine;
using System.Collections;

public class player : MonoBehaviour {

public int x;
public int y;
public int z;
private int speed = 5;
int i;

// Use this for initialization
void Start () {

	transform.position = new Vector3 (x, y, z);

}

// Update is called once per frame
void Update () {

	GameObject sphere;
	GameObject clone;

	transform.Translate (Vector3.right * Input.GetAxis ("Horizontal") * speed * Time.deltaTime);
	transform.Translate (Vector3.forward * Input.GetAxis ("Vertical") * speed * Time.deltaTime);

	if(Input.GetKeyDown ("space")){
		for( i =0; i < 5;i++){
			transform.Translate(Vector3.up * Input.GetAxis("jump") *  i * Time.deltaTime);
			                    }

		                    }
	if(i == 5){
		i = 0;
	}
	 

	if(Input.GetKey ("p")){

		  clone = Instantiate(sphere, new Vector3(2,1,0), transform.rotation);

		clone.rigidbody.AddForce(new Vector3(100,0,0));
	}

}

}

oh haha just relised what you did wrong, to make the instantiated sphere to move you need to instantiate it as a game object first so…

GameObject sphereClone = Instantiate(sphere, new Vector3(2,1,0),  transform.rotation) as GameObject;
sphereClone.rigidbody.AddForce(new Vector3(100,0,0));

Make sure the sphere has a rigidbody and isKinematic is off.