Referencing an instantiated object from a random array

Hey folks,

Probably a very simple answer here, but what I’m trying to do is instantiate prefabbed objects from a randomized array, then dictate their speed via referencing a separate script (SpeederScript). With my current script, I’m getting an error for converting type ‘Object’ to ‘GameObject’, however if I change the type of ‘currentCollider’ to ‘Object’, the rigidbody2d.velocity flares up with errors. Any ideas?

Code below:

public GameObject[] obj;
public float spawnMin = 1f;
public float spawnMax = 2f;
public float changeSpawn = 0.001f;
	
	void Start () {
		Spawn ();
	}

	
	void Spawn () 
	{
		GameObject currentCollider = Instantiate (obj [Random.Range (0, obj.Length)]);
		SpeederScript speeder = gameObject.GetComponent<SpeederScript>();
		currentCollider.rigidbody2D.velocity = new Vector2 (rigidbody2D.velocity.x, speeder.currentSpeed);
			spawnMin = spawnMin - (Time.realtimeSinceStartup * changeSpawn);
			spawnMax = spawnMax - (Time.realtimeSinceStartup * changeSpawn);
		Invoke ("Spawn", Random.Range (spawnMin, spawnMax));
		
	}

Much Thanks in Advance!!!

Try this:

GameObject currentCollider = Instantiate (obj [Random.Range (0, obj.Length)]) as GameObject;