Server and Network no communication

I have a problem with the Network, i create a server and client can connect to it.
But i want get some parameters from server to client i tryed this:

public GameObject server; //have tag “Test” and starting value in number is 0

private GameObject finded;

if (GUILayout.Button(“StartServer”)) {

server.GetComponent<Test_Script3> ().number = 250;
Network.Instantiate(server, transform.position, transform.rotation, 1);


if (Network.peerType == NetworkPeerType.Client) {

    finded = GameObject.FindGameObjectWithTag("Test");
if (finded != null) GUILayout.Label("O: " + finded.GetComponent<Test_Script3>().number);

} else if (Network.peerType == NetworkPeerType.Server) {

			finded = GameObject.FindGameObjectWithTag("Test");
			if (finded != null) GUILayout.Label("O: " + finded.GetComponent<Test_Script3>().number);

The main problem is that value of parameter number on the server is 250 but on the client is 0;

It doesn’t work like that. Each player / peer has it’s own game world and it’s own prefabs. If you change a number on the prefab in the server it won’t change the prefab on any other client.

Some basic points about networking in Unity:

  • Only NetworkViews will be able to transfer data from one PC to another.
  • NetworkViews on different PCs / peers are liked by their NetworkViewID. Those with the same ID can communicate with each other
  • A NetworkView can “observe” a built-in component and have it’s properties synchronised.
  • Only the NetworkView owner can transmit state-updates, everybody else just listens / receives.
  • Apart from state-synchronisation every NetworkView can be used to transmit RPC calls bi-directional. So a client can send an RPC to the server and the server to the client(s)
  • You can’t send RPCs without having a linked NetworkView pair / group. The only indirect exception is Network.Instantiate which uses an RPC behind the scenes but doesn’t require a NetworkView.
  • NetworkViews can also observe a custome script component (aka one of your MonoBehaviour-scripts), but you have to implement the OnSerializeNetworkView callback in that script and specify which data should be transmitted / received.
  • NetworkViews on objects placed in a scene are linked automatically when the client loads the scene.

I suggest to read through the documentation of NetworkView, Network and the Networking basics. Networking isn’t that complicated, but it takes some time until you understand it throughout, so don’t rush, read and learn.

I just added a little code snippet that would do what you want in your question: Transferring a number from the Peer that Instantiated the object to all other clients:

When instantiating:

    int num = 250;
    server.GetComponent<Test_Script3>().number = num;
    GameObject instance = (GameObject)Network.Instantiate(server, transform.position, transform.rotation, 1);
    instance.networkView.RPC("SetNumber", RPCMode.AllBuffered, num);

Inside a script on the “server” object you have to declare this method:

    void SetNumber(int aNum)
        GetComponent<Test_Script3>().number = aNum;

Note: I used a BufferedRPC instead of a “normal” RPC since Network.Instantiate also uses a buffered one. So it’s ensured that when another client joins later the value is set as well.

Personally i don’t like buffered RPCs all together because they almost force you to use them everywhere and Unity doesn’t provide a good way to keep track of / deleting old buffered RPCs.

“Test_Script3” and “number” aren’t really meaningful names so we have no idea what kind of information you try to pass to the client. You have to decide from case to case which kind of RPC is the best one.