Display GUI Text On Network Game?

I am working on a multiplayer game that has it so when you make a server a GUI timer starts to count down when the round will start. However when I join a server I cant see the GUI timer and in the server creators game the timer stops. Here is my code to make the GUI timer when a server starts:

void ServerTimer()
	{
		Debug.Log ("Server Created");
		GameObject textObject = (GameObject)Instantiate(Resources.Load("TimerText"));
	}

So when you make a server it creates the GUI-Text prefab I made.
the Timer code:

using UnityEngine;
using System.Collections;

public class CountdownTimer_CSHARP : MonoBehaviour 
{
	public float Seconds = 59;
	public float Minutes = 0;
	
	void Update()
	{
		if(Seconds <= 0)
		{
			Seconds = 59;
			if(Minutes >= 1)
			{
				Minutes--;
			}
			else
			{
				Minutes = 0;
				Seconds = 0;
				GameObject.Find("TimerText(Clone)").guiText.text = Minutes.ToString("f0") + ":0" + Seconds.ToString("f0");
			}
		}
		else
		{
			Seconds -= Time.deltaTime;
		}
		if(Mathf.Round(Seconds) <= 9)
		{
			GameObject.Find("TimerText(Clone)").guiText.text = Minutes.ToString("f0") + ":0" + Seconds.ToString("f0");
		}
		else
		{
			GameObject.Find("TimerText(Clone)").guiText.text = Minutes.ToString("f0") + ":" + Seconds.ToString("f0");
		}
		
		if(Seconds == 0 && Minutes == 0)
		{
				GameObject spawnObject = (GameObject)Instantiate(Resources.Load("SpawnManager"));
		}
	}
}

I have it so that when the timer ends it will create the SpawnManager which makes the player spawn. When doing my tests the timer and the SpawnManager work, but when I join the server the timer stops and the player that joined cant see the GUI Timer. So, How do I make the timer visible to players that join? Also is there a way to activate a script within another instead of making a prefab?

1 Answer

1

I don’t really understand what you are trying to do here with the timer or why, but to get information from the server to the client or vice versa, you should use an RPC. The function you call on the remote player can take multiple arguments and show a GUIText or do whatever else you want it to.