Public variable on multiple Objects script problem

I have some public var Speed: float and Horizontal: bool in my dragObject.js script.
This script allow me to click and drag (move) tagged objects.
My speed variable allow me to move the object slowly or quickly.
My Horizontal variable allow me to drag horizontally(X-axe) OR vertically (Z-axe).

There is my problem:
When I create 1 cube, the script works well, but when I create 2 cubes, I can’t choose different speed or Horizontal for each object.
Speed will be the same for both object and both object will drag in the same sens.

I want to drag the first cube horizontally and the second vertically with each one different speed, but I CAN’T.
What is the problem?

Thanks!

#pragma strict
private var pickObj: Transform = null;
private var hit: RaycastHit;
private var dist: float;
private var oldPos: Vector3;
private var newPos: Vector3;
var Speed: float = 5.0;
var Horizontal: boolean;

function Start () 
{
	
}

function Update () 
{
	if (Input.GetMouseButton(0))
	{
		var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		if (!pickObj)
		{ 
			if (Physics.Raycast(ray, hit)  hit.transform.tag == "Pick")
			{ 
				if (hit.rigidbody) hit.rigidbody.velocity = Vector3.zero;
				pickObj = hit.transform;
				oldPos = pickObj.position; 
				dist = Vector3.Distance(pickObj.position, Camera.main.transform.position);
			}
		}
		else 
		{
			newPos = ray.GetPoint(dist); 						
			pickObj.position = Vector3.Lerp(pickObj.position, newPos, Time.deltaTime * Speed);		
			
			if(Horizontal)
			{
				if(pickObj.position.z != oldPos.z) pickObj.position.z = oldPos.z;
				if(pickObj.position.x < 0) pickObj.position.x = 0;
				if(pickObj.position.x > 5) pickObj.position.x = 5;
				pickObj.position.y = 0.5;	
			}	
				
			else if(!Horizontal)
			{
				if(pickObj.position.x != oldPos.x) pickObj.position.x = oldPos.x;
				if(pickObj.position.z < 0) pickObj.position.z = 0;
				if(pickObj.position.z > 5) pickObj.position.z = 5;
				pickObj.position.y = 0.5;	
			}
					
		}	
	}
	else { 
		pickObj = null;
	}
}

Are you attaching this to a game object in the hierarchy or a prefab in the project? If it is a prefab in the project, any non-default values you set in the inspector will apply to all objecs you instantiate from that prefab. If it is a game object in the hierarchy, any non-default values you set in the inspector will apply only to that game object.

P.S. Wait more than an hour or two before bumping your post.

it’s not a prefab. So do you know what problem can it be?

Please don’t double post… that’s just annoying…