How can I fix the MissingFieldException Error

So I’ve been trying to make a puzzle game for one of my old teachers. I’ve been working on a script but whenever I use it it gives me this error:

MissingFieldException: System.Single.transform
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter ()
Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name)
Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey17.<>m__C ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
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.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32, Int32)

Here’s the Script:

var Empty : Transform;
var PosY;
var PosX;

function OnMouseUp(){					
		if (Vector3.Distance(transform.position,Empty.position)==1){
		PosY = transform.position.x;
		PosX = transform.position.y;
		PosY.transform.position = Empty.position.y;
		PosX.transform.position = Empty.position.x;
		Empty.position = PosX;
		Empty.position = PosY;
		}
	
	
	
	
	
	
	//empty ray
	var hit : RaycastHit;
	
	//spawn said ray at mouse position
	var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

	if(Physics.Raycast(ray,hit)){
		//Print out the objects name in Console
		Debug.Log(hit.collider.name);
	}	
}

If you could tell me whats wrong and how I could fix it that’d be great. I’ve already tried looking around and unless I’m blind I cant find anything on this. Again any help would be appreciated.

There is an issue with your code that may be causing your problem. To start with put ‘#pragma strict’ at the top of the file. This will generate a number of errors. The primary problem I spot is that on lines 2 and 3 you declare PosY and PosX without a type, which makes them of type Object. Then on lines 7 and 8 you treat them like floats. And then on lines 9 and 10 you treat them like GameObjects. Figure out the type and declare it at the top of the file then fix the code.

Unless you have a strong and informed reason not to, I recommend putting ‘#pragma strict’ at the top of all of your Javascript/Unityscript files.

I have MissingFieldException: System.Single.Length when i ask for

foobar.length
from
function(foobar:float) it shouldn’t compiel but it did.