Problems with moving objects using a script

Welcome. I also created this script to move objects where I need them in the scene, but I have a small problem. If I add a single object in script to move, the object moves, but if I add two or more objects, it doesn’t work anymore, the objects stay in place and I have to press the button twice to make the move work. I tried to add the respective child objects to a main object and it still does the same. Video: https://youtu.be/73aMAcg1SGk

using UnityEngine;
using System.Collections;
using UnityEngine;
public class MoveObject : MonoBehaviour
{
public GameObject[] objectsToMove; 
public Vector3 targetPosition; 
public Vector3 targetRotation; 
public GameObject RaceScripts;
public GameObject RaceCampaign;
public GameObject Race;
public GameObject RCCCanvas;


    public void MoveAndRotate()
    {
        foreach (GameObject obj in objectsToMove)
        {
            obj.transform.position = targetPosition;
            obj.transform.rotation = Quaternion.Euler(targetRotation);
        }

        StartCoroutine(ActivateRaceComponentsWithDelay(0.1f));
    }



private IEnumerator ActivateRaceComponentsWithDelay(float delay)
{
    yield return new WaitForSeconds(delay);
    ActivateRaceComponents();
}

private void ActivateRaceComponents()
{
    RaceScripts.GetComponent<Timer>().enabled = true;
    RaceCampaign.SetActive(false);
    Race.SetActive(true);
    RCCCanvas.SetActive(true);
}


}

What’s the gameObject this script is attached to? Is there just one instance of this script? How are additional game objects objectsToMove added? Are they in fact added to the same MonoBehaviour? How are targetPosition and targetRotation being set and what is calling MoveAndRotate() plus why is ActivateRaceComponentsWithDelay(float delay) being called each and every time within the latter?

there is only one script in the game and in the inspector I can add as many objects as I want in the script, and the coordinates are changed in the same way from the inspector, and I use the ActivateRaceComponentsWithDelay(float delay) function to deactivate certain objects in the game as well.

Any reason you’re not just using a tweener?

Here’s a tweener that is only one single file, iTween.cs

Other people have extended it, and there are plenty of other alternatives if you don’t like iTween

There are dozens of tweeners out there for free.

This is a Very Well Solved Problem™ in the Unity space.