GameObject not moving to correct position

I am making a 2d app and I am using this simple script:

    GameObject.FindGameObjectWithTag("words").transform.position = Vector3.MoveTowards(transform.position, Vector3(-5.269156, 0.9367003,0), 0.05);

That’s literally it. So why is it moving to Vector3(0.2543013, 0.585815,0.9911858)? This makes no sense. It is not working with Vector2 either.

That Vector3.MoveTowards works perfectly fine.

First of all do you use that line of code in reoccurring function? (like Update, FixedUpdate, looped coroutine, etc.) If not then you should to.

Secondly if you use GameObject.FindGameObjectWithTag(“words”) then you should be sure there is an object with tag “words” and it is only 1 like that, otherwise result might not be as you expect it to be.

Also don’t use GameObject.FindGameObjectWithTag(“words”) in reoccurring/looped function, and any other Find whatsoever, in order to increase your performance store reference to script variable like:

private Transform words;
void Start () 
{
    words = GameObject.FindGameObjectWithTag("words").transform;
}

And then use words variable instead.

And finally your problem is in the fact that you change transform of the object you find aka “words” but use transform of the current object as position reference…

P.S. Just for your clear understanding of your problem:

    Transform words = GameObject.FindGameObjectWithTag("words").transform;
    words.position = Vector3.MoveTowards(words.position, new Vector3(-5.269156f, 0.9367003f, 0f), 0.05f);

The current object is words. I do understand why you suggested what you did. If there were two objects in the scene and I put this script on the wrong object, then my words object would start moving from the wrong area and give me a wrong vector3. Honestly I think I’ve done something drastic somewhere else. I thought this might be a glitch that I found, but I will take a closer look at my settings and scripts