Sending Update Transform Through RPC

i have three scripts, i am trying to update the position of sun on client based on where it is in the server, my sun is empty prefab with gametime script which moves its child(foundbyname) but the sun is what is instantiated so the light spawns moving, but when i leave and come back, it just starts over instead of moving and updating based on server, i need help solving the errors and updating the transform.
i get two errors on server, none in client,

—error one

> Couldn't send RPC function 'CheckSun'
> 
> UnityEngine.NetworkView:RPC(String,
> RPCMode, Object[]) DaySpawn:CheckSun()
> (at
> Assets/scripts/server/DaySpawn.js:17)
> DaySpawn:FixedUpdate() (at
> Assets/scripts/server/DaySpawn.js:5)

—error two

> nullreference NullReferenceException:
> Object reference not set to an
> instance of an object
> Boo.Lang.Runtime.RuntimeServices.GetDispatcher
> (System.Object target, System.String
> cacheKeyName, System.Type[]
> cacheKeyTypes,
> Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory
> factory)
> Boo.Lang.Runtime.RuntimeServices.GetDispatcher
> (System.Object target, System.Object[]
> args, System.String cacheKeyName,
> Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory
> factory)
> Boo.Lang.Runtime.RuntimeServices.SetProperty
> (System.Object target, System.String
> name, System.Object value)
> ClientReceive.sendUpdateSunRotate
> (System.String IDNumber, System.String
> PrefabName, Vector3 Position) (at
> Assets/scripts/ClientReceive.js:219)

heres day spawn

> var PrefabName : String;
> 
> function FixedUpdate() { 	CreateSun();
> 	CheckSun(); }
> 
> function CreateSun () {
> 
> 		 PrefabName = "Directional light";
> 	
> 		 		} 	 function CheckSun() { 	 if (!GameObject.Find("PlayerDaySpawn")) {
> 		GameObject.Find("mObject").networkView.RPC("CheckSun",RPCMode.Others,gameObject.name,PrefabName,transform.position);
> 		 	}
>     else if (GameObject.Find("PlayerDaySpawn")) {
> 		GameObject.Find("mObject").networkView.RPC("sendUpdateSunRotate",RPCMode.Others,gameObject.name,PrefabName,transform.position);
> 		 	} 	}

here is SunClient

> private var PrefabName : String;
> 
> 
> function Start () {
> 
> }
> 
> function FixedUpdate () { if
> (Vector3.Distance(transform.position,GameObject.Find("Player").transform.position)
> < 10050) { 		if
> (!GameObject.Find("Player"+DaySpawn))
> { 			var newItem =
> Instantiate(Resources.Load("worlditems/Weathers/Directional
> light1",Transform),Vector3(0,0,0),Quaternion.Euler(Vector3.zero));
> 			newItem.name =
> "Player"+gameObject.name;
> 			newItem.transform.parent =
> GameObject.Find("Sun
> Point").transform;
> 			newItem.transform.rotation =
> GameObject.Find("Sun
> Point").transform.rotation;
> 			GameObject.Find("mObject").networkView.RPC("sendUpdateSunRotate",RPCMode.Others,gameObject.name,PrefabName,transform.position);
> 		} 	} 	}

Here are two functions in client recieve

> @RPC function
> sendUpdateSunRotate(IDNumber :
> String,PrefabName : String,Position :
> Vector3){ 	newItem =
> GameObject.Find(IDNumber);
> 	newItem.name = IDNumber;
> 	newItem.GetComponent("SunClient")
> ``.PrefabName = PrefabName;
> 	newItem.transform.position =
> GameObject.Find("DaySpawn").GetComponent("Directional
> light").Rotation; 	}
> 
> @RPC function CheckSun(IDNumber :
> String,PrefabName : String,Rotation :
> Vector3) { if
> (!GameObject.Find(IDNumber)) { var
> newItem =
> Instantiate(Resources.Load("worlditems/Weathers/sunWeather",Transform),Vector3(0,-100,0),Quaternion.Euler(Vector3(0,0,0)));
> 	newItem.name = IDNumber;
> 	newItem.GetComponent("SunClient").PrefabName
> = PrefabName; 	newItem.transform.position =
> Rotation; } }

Whatever object is being found in sendUpdate does not have a SunClient component attached. You should use Debug.Log statements to track the status of your variables and make sure you’re getting/sending the right information.

Side note: All those strings make it really easy for you to make mistakes which are incredibly hard to find. Using GetComponent(Type) is harder to get wrong, and storing references instead of using .Find all the time improves your performance and prevents you from accidentally finding the wrong object without noticing.