diff --git a/code/datums/elements/photosynthesis.dm b/code/datums/elements/photosynthesis.dm index 8e1c8c53ff..a88a5d108c 100644 --- a/code/datums/elements/photosynthesis.dm +++ b/code/datums/elements/photosynthesis.dm @@ -39,12 +39,13 @@ attached_atoms[target]++ /datum/element/photosynthesis/Detach(datum/target) - attached_atoms[target]-- - if(!attached_atoms[target]) - attached_atoms -= target - if(!length(attached_atoms)) - STOP_PROCESSING(SSobj, src) - attached_atoms = null + if(attached_atoms) + attached_atoms[target]-- + if(!attached_atoms[target]) + attached_atoms -= target + if(!length(attached_atoms)) + STOP_PROCESSING(SSobj, src) + attached_atoms = null return ..() /datum/element/photosynthesis/process()