AI problem

When I type this code, I get this error

Operator ‘>’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘float’.

Is there a way to fix this code?

{
	Distance = Vector3.Distance(Target.position, transform.position);
	
	if (Distance < lookAtDistance)
	{
		lookAt();
	}
	
	if (Distance > lookAtDistance)
	{
	
	}
	
	if (Distance < attackRange)
	{
		attack ();
	}
}

make sure the “Distance”-variable is a float-type variable, eg;

float Distance;    
Distance = ( Target.position - transform.position ).magnitude;

Also make sure the “attackRange”-variable is a float-type variable :slight_smile: