Tilt dragging problem to right

I am making game , and i have implementd tilt controls for it it works but the problem is that when game starts my player is by default drraging to right direction without any tilt…here is code that i am writing plz help me thanzz in advance

var dir: Vector3 = Vector3.zero;

dir.x = Input.acceleration.x;
if (dir.sqrMagnitude < 0.5)
{

transform.Translate(dir );

}

Hello asad113,
I have looked over your code and posted my changes below (Not tested.)
Unity Script Reference: Unity - Scripting API: Input.acceleration

var speed = 10f;
function Update() {
  var dir: Vector3 = Vector3.zero;
  
  dir.x = Input.acceleration.x;
  if (mathf.abs(dir) > 0.5)
    transform.Translate(dir*Time.deltaTime*speed);//Time.deltaTime is the time between frames and it keeps the movement the same even when the frame changes.

}

ACMaier