Problem with Instantiate GameObject in loop

public class Duplication : MonoBehaviour
int pelletdup = 10;
public float spawnpt = 0.91f;
// Start is called before the first frame update
void Start()
if ( == "PeletPac")
a = spawnpt;
for (int i = 0; i < pelletdup; i++)
gameObject clone = Instantiate(gameObject clone , Vector3(transform.position.x + a, transform.position.y, 0), Quaternion.identify);
a += spawnpt;

this is my code and for a reason it doesn't work. It says that on line 13 which is on gameObject clone =......, on the 59 word there is Syntax.error "," expected.

Please use Code Tags when posting code on the forum.

Lots of stuff I can already see wrong.

  • gameObject is not a type, it's a variable reference to the script's owner GameObject. The actual type has a capital G.
  • Instantiate's first parameter takes an object it wants to clone, if you want it to copy the object the script is on, just say gameObject instead of what you have.
  • You never declare what 'a' is, and you're trying to manipulate that value.

Do yourself a favor and download a good IDE, Visual Studio Community Edition is free and has some stuff that makes it work well with Unity. It'll do stuff like tell you where you have syntax errors.


Thanks for the suggestion, Got it working perfectly fine now

You don’t need to use the forum to fix your typos.

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.