FindInBox

So I made this;

[LUA]
local function AntiSpawnBlock()
local props = {}
props = ent.FindInBox(Vector(-215,-693,-193), Vector(1338,-365,175))
for i = 0, table.Count(props) do
if (props*:GetClass() == “prop_physics”) then
props*:Remove()
end
end
timer.Simple(0.5,AntiSpawnBlock)
end
timer.Simple(0.5,AntiSpawnBlock)
[/LUA]

And it doesn’t work, it gives me this;

[LUA]
Timer Error: [lua\autorun\server\antispawnblock.lua:3] attempt to index global ‘ent’ (a nil value)
[/LUA]

Help!

its ents , not ent.



local function AntiSpawnBlock()
    local props = ents.FindInBox(Vector(-215,-693,-193), Vector(1338,-365,175))
    for i = 1, #props do
        if (props*:GetClass() == "prop_physics") then
            props*:Remove()
        end
    end
    timer.Simple(0.5,AntiSpawnBlock)
end
timer.Simple(0.5,AntiSpawnBlock)



local min = Vector(-215,-693,-193)
local max = Vector(1338,-365,175)
local function AntiSpawnBlock()
    local props = {}
    props = ents.FindInBox(min, max)
    for i = 1, #props do
        if (props*:GetClass() == "prop_physics") then
            props*:Remove()
        end
    end
    timer.Simple(0.5,AntiSpawnBlock)
end
timer.Simple(0.5,AntiSpawnBlock)

Localize the vectors.
You do not even need table.Count(props). Use #props. It is quicker and it is what you actually need.

[editline]asd[/editline] And of course, ents, not ent.

[editline]…[/editline] Array indices start at 1, not 0.
Fixed the code.

Ah i didn’t notice the array indices.
As for the locals, they are not needed. You are referencing data that is only used once. You can keep them as they are.