using user input to create ongui player display

Im trying to create a player display using OnGUI that is a base object, while accepting user input from a seperate user interface in another class. I want to take that input and create that many player displays. Im going to create another class that holds both interfaces, so it will first pop up and ask how many players. then based on that number it will create that many user displays, each one having an (offset * n) so that they are spaced out appropriately. im not sure if im even going about this the right way so here is my code. i tried using an array with a foreach to initialize each display. Any and all help will be appreciated.

here is my playerdisplay script

using UnityEngine;
using System.Collections; 
using System;

public class PlayerDisplay : MonoBehavior {
        private int life;
        private bool isalive = true;
        private int minlife = 0;
        private const int OFFSET = 50;
	private int n;
	private const int XAXIS = x;
	}
void Start() {
}

void Update() {
}

public void OnGUI(){
	DisplayPlayerDisplay();
	DisplayLifeStats();
}

public void DisplayPlayerDisplay() {
	GUI.Box(new Rect(XAXIS + (OFFSET * n),y,x,y), “Player”);
}
public void DisplayLifeStats() {
	GUI.label(new Rect(XAXIS + (OFFSET * n),y,x,y),”life”, life.ToString());
	If(GUI.Button(new Rect(x,y,x,y), “+“)
		life++;
	If(GUI.Button(new Rect(x,y,x,y), “-”) {
		life--;
		if(life  <= minlife;){
			life = minlife;
		}
		return life;
		}
	}
 and here is my player counter script

using UnityEngine;
using System.Collections;
using System;

public class PlayerCounter : MonoDevelopment {
	private int pa = 2;
	private int minpa = 2;
}

void Start() {
	
}

void Update() {
}

public void OnGUI() {
	DisplayPlayerCounter();
}

public void DisplayPlayerCounter() {
	GUILayout.BeginArea(new Rect(x,x,x,x));
	If(GUILayout.Button(“-”)) {
		pa--;
		}
		If(pa <= minpa)
		pa = minpa;
	If(GUILayout.Button(“+”)) {
		pa++;
	if(GUILayout.Button(“Done”)) {
		return pa;
		}
	GUILayout.EndArea();

and my player script that ties them all together

using UnityEngine;
using System.Collections;
using System;

public class Player : MonoBehaviour {
	public int life = 20;
	PlayerCounter pc = new PlayerCounter();
	PlayerDisplay pd = new PlayerDisplay();
	public Int n;	
}

void Start() {	
	int n = pc.DisplayPlayerCounter();
}

void Update() {

Public void PlayerCreation() {
	Players player[] = new Players(n);
	Foreach(int newplayers in player)
{	
		Pd.DisplayPlayerDisplay();
		Pd.DisplayLifeStats();
	}
}

ok got it

1-if u want to create multiple objects on the fly, then yes make your player a prefab

2-change or create a playerFacotry script and attach it to an empty object on scene

3-this class should have a public GameObject so we can set the prefab in the inspector

public GameObject prefabPlayer;

4-this class should aslo have a function named something like CreatPlayers() that will handle the Instantiate

GameObject tmpPlayer = Instantiate(prefabPlayer);

5-now i dont see an actual button that start the script, so make a button that u press at the end when u want to create all your players

GameObject.find("playerFacotryObject").GetComponent<playerFacotry>().CreatePlayers();

6-now you need to pass your player counter values to the factory before any new objects are created, you can do it from 1 place or another

or you can do it when the gui numbers are changed , in this case u make the same variables in the factory public and from the counter u populate this variables

or you can do it when u press the final buttons in the CreatePlayer script u can go get the variables from the counter directly, if so make sure to make the couter variables public

float numFromCounter = GameObject.find("nameofobject").GetComponent<PlayerCounter>().minpa;
float offset = 2;
tmpPlayer.transform.position = new Vector3(numFromCounter * offset , 0 ,0);

edit

thinking a bit more, it might even be wiser to pass the variables from the gui when the button is pressed. here is the CreatePlayer functino i came up with for your factory

public GameObject prefabPlayer;
public void CreatPlayers(int numToCreate){
	float offset = 2;
	for(int i = 0; , i < numToCreate; , i++){
	tmpPlayer.transform.position = new Vector3(i * offset , 0 ,0);
	}
}

now all u goto do is , in your gui code, when the final button is pressed u run

GameObject.find(“playerFacotryObject”).GetComponent().CreatePlayers(minpa);

ok , im not to sure cause i quiclky glanced at the code

but in your player script that holdes it all toghter this is wrong

 PlayerCounter pc = new PlayerCounter();
PlayerDisplay pd = new PlayerDisplay();

you can instead do

PlayerCounter pc = GameObject.find("nameofobject").GetComponent<PlayerCounter>();

All monobehaviour scripts are already contrsucted when the scene loads, so u simply need to refrence it