Can't remove ragdolls on map with specific model


for k, v in pairs(ents.GetByModel("models/stalkertnb/dog1.md")) do k:Remove() end

I run this from console( lua_run) but seems like this does nothing. These damn mutant dog ragdolls make heavy load on server.
I tried different variants - no effect. I am sure that i typed correct model!
What should i do?

firstly, there’s a typo in the model name, models end with .mdl not .md


ents.GetByModel("models/stalkertnb/dog1.md")

should be


ents.GetByModel("models/stalkertnb/dog1.mdl")

secondly, in your loop you are trying to call Remove() on the key, rather then the entity, which would be the value, so


k:Remove()

would become


v:Remove()

[editline]4th August 2017[/editline]

and thirdly, which i just noticed now like an idiot, ents.GetByModel doesn’t even exist, it’s

ents.FindByModel

Damn, thank you a lot! I’ll check this out.

[editline]4th August 2017[/editline]


for k, v in pairs(ents.FindByModel("models/stalkertnb/dog1.mdl")) do v:Remove() end

Still not works. What i’m doing wrong?

Where are you calling this? Are you sure the model is correct?

I use lua_run. Model is correct, bcs when i spawn it, console shows right model path.

Are those ragdolls server? Like can you grab those with physic guns? If you can’t, then you have to run that in clients since those could be client side ragdolls

These ragdolls are server. I don’t know how the hell VJ SNPCs addon remain after NPC death his server ragdoll. Yep, i can dupe it or move with physgun.

I forgot to show the error code, sorry!


[ERROR] lua_run:1: attempt to perform arithmetic on global 'models' (a nil value)
  1. unknown - lua_run:1



Solved! Maybe someone will need it :slight_smile:


for k, v in pairs(ents.GetAll()) do if v:IsRagdoll() then v:Remove() end end

That will remove ANY ragdoll in map, even the ones in level

That’s what i need. I got StalkerRP server and damn mutant ragdolls make a heavy load on server.