GameObject.FindwithTag Crash

Ok, so I’m trying to be professional on using unityscript, but I found an issue that crashes unity. The code is…

In game controller gameobject a script called EntityFinder…

public GameObject ship;
public GameObject[] rocks;
public GameObject[] pellets;

// Update is called once per frame
void FixedUpdate () {
	ship 	= GameObject.FindGameObjectWithTag(Tags.player);
	rocks 	= GameObject.FindGameObjectsWithTag(Tags.badThing);
	pellets = GameObject.FindGameObjectsWithTag(Tags.projectile);
}

In camera a script called ScreenBorder…

void Awake() 
{
	entityFinder = GameObject.FindWithTag(Tags.gameController).GetComponent<EntityFinder>();
}

void Update()
{

	Border (entityFinder.ship.transform, shipBuffer);

	if (entityFinder.rocks.Length > 0)
		for (int r = 0; r < entityFinder.rocks.Length; r++){
			Border (entityFinder.rocks[r].transform, rockBuffer);
		}

	if (entityFinder.pellets.Length > 0)
		for (int p = 0; p < entityFinder.pellets.Length; pelletBeffer++){
			Border (entityFinder.pellets[p].transform, pelletBeffer);
		}

 }

Unity crashes every time it finds a pellet (weapon projectile).

Any ideas to why it crashes and is there any work arounds?

Your problem is on line 9. You are incrementing ‘pelletBuffer’, but you are not incrementing ‘p’. So your app hangs, since ‘p’ is never greater than ‘pellets.Length’.