AI movement script won't move the object.

I did some debugging and it does assign the target position for the object to move to, just the object isn’t moving to it. Why is this? Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class creature : MonoBehaviour
{
	//creature stats
	public int strength;
	public int speed;

	//script utilities
	int oldIteration = 0;
	public Vector3 targetPos;
	gameController controller;

	//eating 
	public bool vegetarian = false;
	public bool carnivore = false;
	public bool omnivore = false;

	void Start()
	{
		//script utilities
		controller = Camera.main.GetComponent<gameController>();
		targetPos = transform.position;

		//stats
		strength = Random.Range(0, 6);

		//eating
		int randDietForm = Random.Range(0, 3);
		switch (randDietForm)
		{
			case 0:
				vegetarian = true;
				break;
			case 1:
				carnivore = true;
				break;
			case 2:
				omnivore = true;
				break;
		}
	}

	void Update()
	{
		//iterative things
		if (controller.iteration > oldIteration)
		{
			//findCreatures();
			moveCreature();
			oldIteration++;
		}

		//continuous things
		transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
	}
	/////////////////////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////// Movement ///////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////

	//Moves the creature to a random surrounding available position
	void moveCreature()
	{
		//positions
		Vector3 creaturePos = transform.position;
		List<Vector3> neighbourPositions = availableNeighbourPositions(creaturePos.x, creaturePos.y);
		int rand = Random.Range(0, neighbourPositions.Count);
		Vector3 tempTargetPos = neighbourPositions[rand];

		Collider2D[] hitColliders = Physics2D.OverlapCircleAll(creaturePos, 2f);
		for (int i = 0; i < hitColliders.Length; i++)
		{
			if (hitColliders_.GetComponent<creature>().targetPos == tempTargetPos && hitColliders*.transform.position != creaturePos)*_

* {*
* rand = Random.Range(0, neighbourPositions.Count);*
* }*
* }*

* targetPos = neighbourPositions[rand];*
* }*

* //accesses the available (positions without colliders) neighbour positions of a position*
* List availableNeighbourPositions(float posX, float posY)*
* {*
* List positions = new List();*
* Vector3 pos = new Vector3(posX, posY, 0);*

* for (int i = -1; i < 2; i++)*
* {*
* for (int j = -1; j < 2; j++)*
* {*
* float neighbour_x = posX + i;
float neighbour_y = posY + j;*

* Vector3 neighbourPos = new Vector3(neighbour_x, neighbour_y, 0);
_
positions.Add(neighbourPos);_
_
}_
_
}*_

* Collider2D[] hitColliders = Physics2D.OverlapCircleAll(pos, 1f);*
* for (int index = 0; index < hitColliders.Length; index++)*
* {*
* for (int i = 0; i < positions.Count; i++)*
* {*
_ if (hitColliders[index].gameObject.transform.position == positions*)
{
positions.Remove(positions);
}
}
}
return positions;
}*_

* //accesses the neighbour positions of a position*
* List neighbourPositions(float posX, float posY)*
* {*
* List positions = new List();*
* for (int i = -1; i < 2; i++)*
* {*
* for (int j = -1; j < 2; j++)*
* {*
* float neighbour_x = posX + i;
float neighbour_y = posY + j;
_ if (i == 0 && j == 0)
{*_

* }*
* else*
* {*
* Vector3 pos = new Vector3(neighbour_x, neighbour_y, 0);
_ positions.Add(pos);
}*_

* }*
* }*
* return positions;*
* }*

}
I have a feeling that it has to do with this line: transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
but I’m not sure what is wrong with it. My script is supposed to choose a random position (which it does) and then move the object based off of that. The game is in 2d, so the z position of the Vector3 is always 0.

https://www.udemy.com/course/turn-based-strategy-game-development/
Turn based game dev tutorial like heroes of might and magic

Has the gameObject a rigidbody?