diff --git a/code/entity.lua b/code/entity.lua index 01855ec..c5cdbec 100644 --- a/code/entity.lua +++ b/code/entity.lua @@ -309,7 +309,7 @@ end function cleanDeadEntities() for i=1, #LoadedObjects.Entities do enty = LoadedObjects.Entities[i] - if enty.dead then + if enty and enty.dead then table.remove(LoadedObjects.Entities,i) end end diff --git a/code/lights.lua b/code/lights.lua index e50b7f3..4a3351a 100644 --- a/code/lights.lua +++ b/code/lights.lua @@ -80,7 +80,7 @@ end function cleanDeadLights() for i=1, #LoadedObjects.Lights do light = LoadedObjects.Lights[i] - if light.dead then + if light and light.dead then table.remove(LoadedObjects.Lights,i) end end