A box is going to follow a simple path (Doesn't work).

So I am trying to make a box follow a path consisting of 5 empty game objects scattered around the map. The 5 empty GameObjects names are Waypoint 1 up to Waypoint 5. I have doubled checked at least 5 times. Whenever I run my code I get no error, but my Box Object just spins around. Debug.log(currentwaypoint) is always zero which is understandable. Even though I can probably find a code on the internet that has zero problems, I want to understand why this doesn’t work when it seems 100% logical in my eyes.

using UnityEngine;
    using System.Collections;
    
    public class Moveto : MonoBehaviour {
        public Transform[] waypoints = new Transform[5]; 
        float speed = 50;
        int currentwaypoint = 0;
    
        void Start () {
            waypoints[0] = GameObject.Find("Waypoint1").transform;
            waypoints[1] = GameObject.Find("Waypoint2").transform;
            waypoints[2] = GameObject.Find("Waypoint3").transform;
            waypoints[3] = GameObject.Find("Waypoint4").transform;
            waypoints[4] = GameObject.Find("Waypoint5").transform;
          
        }
    	
    	void Update () {
            
            if (currentwaypoint < waypoints.Length) {
    
                transform.position = Vector3.MoveTowards(transform.position, waypoints[currentwaypoint].position, speed * Time.deltaTime);
                transform.LookAt(waypoints[currentwaypoint]);
                Debug.Log(currentwaypoint);
                if (gameObject.transform.position == waypoints[currentwaypoint].position)
               {
                   currentwaypoint++;
               }
                
            }
        }
    }

The code works fine, tested it just now. Check if your waypoints are named correctly. If it still spins around in the same place, try changing

(gameObject.transform.position == waypoints[currentwaypoint].position)

to something like

if(Vector3.SqrMagnitude(waypoints[currentwaypoint].position - gameObject.transform.position) < 0.0001f)

to account for floating point precision.