Problem instantiating (C#): Expression denotes a type where...

This one is baffling me. I’m looking at code from old projects where I’ve instantiated an object and in script I’ve done this:

public GameObject ballInQueue;//drag and drop BallInQueue object in inspector


//later in the same file
private void AddQueueBall(Vector3 ballPosition)
{
GameObject tempBall = (GameObject)Instantiate(ballInQueue, ballPosition, Quaternion.identity);

tempBall.GetComponentInChildren<BallInQueue>().moving = false;
}

This has worked without a problem. Now I’m trying to do the same thing following the same steps with an object called SmallButton and I get an ‘Expression denotes a ‘type’, where a ‘variable’, ‘value’ or ‘method group’ was expected’ error.

The SmallButton object has a SpriteManager2 packed sprite script attached to it with an atlas that was created just fine and a SmallButton script which is empty (the default script you get when you create a Monodevelop script within Unity and renamed to ‘SmallButton’

I’ve compared objects from my old project which compiled just fine with the new object which gives the error and I can’t see what I’m doing wrong. Any ideas?

The problem might be this: is your “SmallButton” game object named the same as your “SmallButton” script? This might confuse the compiler. Try renaming your game object. Also make sure that the variable you’re declaring (“public GameObject ballInQueue” in the above example) has a different name as well.