if transform.position == 5 Change the Scale of game object

#pragma strict

var player : GameObject;
function Start()
function Update()

if (transform.position.x == 5) {
	player.transform.localScale.x = 4;
if (transform.position.x == -5) {
	player.transform.localScale.x = -4;


i make gameObject and i wanna this game object rotation when its position equeal 5
i use the code above and nothing happen any thing
sorry for my english because my age is 13 and my native language is niot english

transform.position.x is a float value, and you should not compare float values with == because you will have precision problems. The same float number might have slightly different representations. Use Equals(float) method instead:

if (transform.position.x.Equals(5.0f))

On the other hand, localScale scales the object but does not rotate.