Object's localScale

I have a script that shows me what object i’m looking at. I would like to know that object’s localScale.

For example if i’m looking at 1 x 1 x 1 object it would look like:

x = 1
y = 1
z = 1

I want to see it in script.

I know how to do it. I used this:

X = lookingAt.gameObject.GetComponent<Transform>().localScale.x;
Y = lookingAt.gameObject.GetComponent<Transform>().localScale.y;
Z = lookingAt.gameObject.GetComponent<Transform>().localScale.z;