I am having a problem within the engine...sometimes my code below will result in a Invalid Array Index Error. Which I know cant be right but maybe I am missing something. If anyone could please take a look and if you see something that would cause that problem give me a hand. I would really appreciate it. I can post more of the code if needed but these are the lines that will return the error so I just included this loop

Code:
 while(1)
{
CurSPartPos[SwordPartCount] = PrevSwordPartIn1.x + cos(CurSPartAng.pan) * cos(CurSPartAng.tilt) * SwordPartCount2;SwordPartCount += 1;
CurSPartPos[SwordPartCount] = PrevSwordPartIn1.y + sin(CurSPartAng.pan) * cos(CurSPartAng.tilt) * SwordPartCount2;SwordPartCount += 1;
CurSPartPos[SwordPartCount] = PrevSwordPartIn1.z + sin(CurSPartAng.tilt) * SwordPartCount2;SwordPartCount += 1;SwordPartCount2 += 0.1;

CurSPartFade[CurSPartFadeCount] = CurSPartFade[CurSPartFadeCount - 1] + CurSPartFadeAmount;
CurSPartFadeCount += 1;
if((SwordPartCount / 3) >= Partthistime){SwordPartCount = 0;CurSPartFadeCount = 0;break;}
}