remove all hl2 guns on a map

I need help with a code that can remove all hl2 weapons from a map.

I already tried to make something, but it doesent work(im a big Lua noob)

Here’s the code:

function removeguns()

local guns = ents.FindByClass("weapon_*")

hook.Add("Initialize", "removeguns", removeguns)

can you please help me?

ents.FindByClass returns a table of entities, so you have to loop through all of them to remove them
InitPostEntity is called when all entities are spawned and loaded, initialize is not.

function removeguns()
local guns = ents.FindByClass(“weapon_*”)
for k,v in pairs(guns) do
hook.Add(“InitPostEntity”, “removeguns”, removeguns)[/lua]

Also, post your code in [noparse][lua][/lua][/noparse] tags next time

Thank you very much it works now!