diff --git a/maps/crab_defender/main.lua b/maps/crab_defender/main.lua index c9c48855f..21ac04efa 100644 --- a/maps/crab_defender/main.lua +++ b/maps/crab_defender/main.lua @@ -1125,17 +1125,17 @@ local function deny_building(event) return false end -local on_built_entity = function(event) +local on_built_entity = function (event) local get_score = Score.get_table().score_table local this = FDT.get() local entity = event.created_entity - local surface = entity.surface - if not surface or not surface.valid then + if not entity or not entity.valid then return end + local surface = entity.surface - if not entity.valid then + if not surface or not surface.valid then return end