ents.FindByName doesnt work!

ok so i have

safes = ents.FindByName(“safe”)
Msg(“TESTING FOR safes (”…tostring(table.Count(safes))…")

and it doesnt find ANY entities by target name of “safe” its in the init.lua and yeah…
Oh and is the target name the “Name” in the entity of Source SDK, like in its properties?

If you are using it client-side I believe it won’t work because **[Entity.GetName

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetName)** is server-sided so I high doubt that function will work client-sided.

i just said that i put it in init.lua (server side)

Saying you put it in “init.lua” doesn’t mean it has to be serverside.

Anyway, try doing something like this.

for k,v in ipairs( ents.GetAll() ) do
if string.lower( v:GetName() ) == “safe” then

still doesnt work maybe i placed the “safe” name into the wrong part…where do you set a props name in Source SDK? in its properties “Name”?

Yep, that’s where it would find it by name. ent_setname does the same thing.

It probbably dosent work due to the map not being fully loaded when the scripts is ran? try this:
[lua]hook.Add(“InitPostEntity”, “SafeCheck”, function()
safes = ents.FindByName(“safe”)
Msg(“TESTING FOR safes (”…tostring(table.Count(safes))…")

InitPostEntity is ran when all entities is spawned