Copying Prefeb via Instantiate multiplies it uncontrollably

As the title says, im trying to copy a prefab the moment it does Start()

	void Start () {
		plyGO = GameObject.Find("ply");

		if (spellIsCopyFloat <= 0)
		{
			GameObject.Find("M1_firstSyllableGameObject").SendMessage("SpellStartTick", gameObject);
			Debug.Log("im the original");
		}
		else
		{
			Debug.Log("IM A COPY");
		}
		gameObject.name = "Fire1Bullet";
	}

Which then calls a function in a different script:

	public void SpellStartTick(GameObject senderGO)
	{
		GameObject senderCopy = Instantiate(senderGO, senderGO.GetComponent<Transform>());
		senderCopy.GetComponent<Fire1Script>().spellIsCopyFloat += 1;
	}

And everything until here works fine, however if I try to instatiate more then one of the copys with either a while-loop or just copying the code, the amount of copys seem to increase by (2^“Amount of copys”) in other words:

1 copy = 2,
2 copys = 4,
3 copys = 8
and well that means i cant for example do a while loop to just create 6 copys because that would just spawn 64.

Im kind of new to c# so I have no idea why this happens

Edit: misscalculated 2^6 (wrote 36 before)

I’m fairly certain what’s happening is that the call to the Instantiate in SpellStartTick is causing the Start() method to fire before you set spellIsCopyFloat, so it recurses. You can actually test for copies by not changing the name of the gameObject. Unity appends " (Clone)" to instantiated prefabs. You can remove spellIsCopyFloat if you don’t use it elsewhere and instead write:

// Test for original
if (!name.Contains(" (Clone"))

then later in the method, don’t set the object name.

Alrigth to fix this problem I basically just added one more step before cloning the Prefab in other words a made a new GameObject that only does this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class baseSpellScript : MonoBehaviour {

	public GameObject initSpellPrefab;

	void Start () {
		string selfName = gameObject.name;

		GameObject newInitSpell = Instantiate(initSpellPrefab, gameObject.transform);
		newInitSpell.name = "Spell1_";

		GameObject.Find(selfName + "_firstSyllableGameObject").SendMessage("BaseSpellInit", gameObject);
		GameObject.Find(selfName + "_secondSyllableGameObject").SendMessage("BaseSpellInit", gameObject);
		GameObject.Find(selfName + "_thirdSyllableGameObject").SendMessage("BaseSpellInit", gameObject);
		GameObject.Find(selfName + "_fourthSyllableeGameObject").SendMessage("BaseSpellInit", gameObject);
	}
}

with this i can just copy “initSpellPrefab” so the SendMessage calls dont loop.

If anyone ever finds out why exactly it did increase exponantionally i would be glad to find out, because tbh the current code is just kind of ugly.