how to pass objects from a findgameobjectswithtag function

This function seems to fail anytime I try to pass the objects found into another script. It gives a null reference exception. I have a similar set of code running fine using only unity premade functions.

var wheels = GameObject.FindGameObjectsWithTag("wc");
	for(var cores : GameObject in wheels)
	{
		print(cores.name);//this line works fine
		//var temp : GameObject = cores[0]; //should I be using this?
		cores.GetComponent(ScriptGeneralDeck).draw(cores.transform, cores.name, 5,5,0 );

//changing cores.name to cores.transform.name causes errors claiming to destroy assets

	}

Javascript’s lazy-typing is hurting you here. Add #pragma strict at the top of the script to prevent it happening in the future (sometimes it’s convenient to drop strict, but I wouldn’t normally recommend it)

Wheels is a GameObject. Cores (plural variable name when it’s not an array; gonna confuse ya) is a single GameObject. Any cores which doesn’t have a ScriptGeneralDeck component attached will throw a null-ref when you attempt to use its .draw function (since that’s how things do).