blast damage causes infinte loop

Hi there.
I’m new to facepunch and i was just wondering if anyone can help me with a little problem i’m facing with a Lua script that i have made.
What the script does: gives all props spawned health depending on the mass
The problem i am having: when a prop explodes it has a 50% chance of dealing damage to nearby props. But when it does this and if another prop explodes because of this it deals damage to the original prop that exploded causing the ent:Remove() function to never run and thus is stuck in an infinite loop

here is the portion of the code that is causing the problem

if spd[ent:EntIndex()] < 1 then
local effect = EffectData()
local ExplosionSound = Sound( “big_explosion.wav” )
effect:SetStart(ent:GetPos())
effect:SetOrigin(ent:GetPos()+ Vector(0, 0, 10))
effect:SetScale(mass)
util.Effect(“Enersplosion”, effect)
ent:EmitSound( ExplosionSound, 90, 100)
–> local Pos = ent:GetPos()
ent:Remove()
if math.random( 1, 100 ) > 50
then

		local inflictor = DamageInfo:GetInflictor()
		local attacker = DamageInfo:GetAttacker()
		util.BlastDamage( inflictor, attacker, Pos + VectorRand() * 30, 500, 300 ) &lt;--
					
		end
    end

Any help is appreciated thanks :smile:

Firstly, please use [noparse]


 or [lua][/noparse] tags when quoting code, it makes for easier reading. If damage-feedback is the problem, then having a *dead* variable in the entity's table that determines whether or not the entity will accept/process damage will prevent this, i.e.

[lua]if ent.health &lt;= 0 && !ent.exploded then
   ent.exploded = true

   --effect/damage code
end[/lua]

Well i’ll know for next time. Thanks i will implement that now.