Map Vote Error. Please help me

I got an error.

******* script runtime error *******
removed entity is not an entity: (file ‘/_mapvoting.gsc’, line 206)
level.MapVoteHud[0] destroy();

CreateHud()
{
    level.MapVoteHud[0] = newHudElem();
    level.MapVoteHud[0].hideWhenInMenu = true;
    level.MapVoteHud[0].alignX = "center";
    level.MapVoteHud[0].horzAlign = "fullscreen";
    level.MapVoteHud[0].vertAlign = "fullscreen";
    level.MapVoteHud[0].x = 320;
-------

I have already defined the hud I think.

error occurs at


+204 DeleteHud()
+205 {
+206    level.MapVoteHud[0] destroy();
    level.MapVoteHud[1] destroy();
    level.MapVoteHud[2] destroy();
    level.MapVoteHud[3] destroy();
    level.MapVoteHud[4] destroy();
    level.MapVoteNames[0] destroy();
    level.MapVoteNa

I would need the entire script to see what’s happening.

What that error is telling you is the entity you want it to destroy is undefined. You can add a safeguard for that like this:

DeleteHud()
{
if(isDefined(level.MapVoteHud)) {
    for(i=0;i<5;i++) {
        if(isDefined(level.MapVoteHud[i]))
            level.MapVoteHud[i] destroy();
    }
 }
if(isDefined(level.MapVoteNames)) {
    for(i=0;i<5;i++) {
        if(isDefined(level.MapVoteNames[i]))
            level.MapVoteNames[i] destroy();
    }
}

Good luck