Spawning a Zombie at every prop_physics within a radius?

Hello, I’m working on a new SWEP and want to know how to do something, such as spawning a Zombie at every “prop_physics” within a certain radius from the player.
This isn’t exactly what I want to do, but I think it’s a good enough example, as stupid as it may sound.

Below are some things I know how to use on their own, but not in this context.

luafor k, v in pairs(ents.FindInSphere(self.Owner:GetPos(), 1200))[/lua]

lualocal myNPC = ents.Create( “npc_zombie” )[/lua]

I’d be greatful for any help.

Here’s the general structure with the parts you provided:


-- Use self:GetOwner() instead of self.Owner!
local tEntities = ents.FindInSphere(self:GetOwner():GetPos(), 1200)

-- Numeric-for is faster here since it's a sequential table
for i = 1, #tEntities do
	local pEntity = tEntities*

	if (pEntity:GetClass() == "prop_physics") then
		local pZombie = ents.Create("npc_zombie")

		-- Hit the entity limit
		if (not pZombie:IsValid()) then
			break
		end

		pZombie:SetPos(pEntity:GetPos() + whatever)
		pZombie:Spawn()
	end
end

Wow, this worked perfectly, thank you so much. :happy: