lastragcount = 0 function thinkShit() local ragcount = 0 for i=1,4096 do local ent = ents.GetByIndex(i) if ent:IsValid() then if ent:GetClass() == "prop_ragdoll" then ragcount = ragcount + 1 end end end if ragcount > lastragcount then --do your shit here end lastragcount = ragcount end