Stopping players from spawning props on player spawn zones ??

Is there a way to stop players from spawning props on the spawn point ?

Yes, you would hook into the spawning hook, define the spawn area, and return false if the vector is inside the area. Let me whip up some code for you.


– Copyright © 2012 , James Swift
– This script is under this license :

local SpawnPoint = {

Min = Vector(-100 ,-100 ,-100 ),
Max = Vector( 100 , 100 , 100 )


hook.Add( “PlayerSpawnObject”, “AntiSpawn”, function( Player, Model , Entity )

local position = Entity:GetPos( )
local InAreaX = ( position.x > SpawnPoint.Min.x and position.x < SpawnPoint.Max.x )
local InAreaY = ( position.y > SpawnPoint.Min.y and position.y < SpawnPoint.Max.y)
local InAreaZ = ( position.z > SpawnPoint.Min.z and position.z < SpawnPoint.Max.z)
local Inarea = ( InAreaX and InAreaY and InAreaZ )

if ( Inarea and not ( Player:IsAdmin() ) )then
	Entity:Remove( )
	 -- If the object is in the area, delete it if not admin



Or, You could use Ents.FindInBox and compare the results.

local SpawnPosMin = Vector(0,0,0)
local SpawnPosMax = Vector(100,100,100)
for k,v in pairs(ents.FindByClass("prop_physics")) do
if (((v:GetPos().x > SpawnPosMin.x) && (v:GetPos().y > SpawnPosMin.y) &&( v:GetPos().z < v:SpawnPosMin.z ) && ((v:GetPos().x < SpawnPosMax.x) && (v:GetPos().y < SpawnPosMax.y) &&( v:GetPos().z < SpawnPosMax.z )))then

Only way if you dont want people spawning props out side of the spawn and placing them inside.


local SpawnPosMin = Vector(0,0,0)
local SpawnPosMax = Vector(100,100,100)

do – Why do we need new chunk here?
for k,v in pairs(ents.FindByClass(“prop_physics”)) do
if (((v:GetPos().x > SpawnPosMin.x) && (v:GetPos().y > SpawnPosMin.y) &&( v:GetPos().z < v:SpawnPosMin.z ) && ((v:GetPos().x < SpawnPosMax.x) && (v:GetPos().y < SpawnPosMax.y) &&( v:GetPos().z < SpawnPosMax.z )))
– Or you could save the position in a local variable and not call Entity:GetPos() 6 times per entity per frame?

– Missing an end here, for the new chunk you made …
– And you need to put it in the think hook, otherwise it’s just plain useless…

Also, Indented code is easier to read, and you would have noticed the missing end more easily.
What you did is exactly what I did, except without adding hooks, creating useless chunks, overusing functions ( 6 calls per entity per frame? ), and missing an end.

Fixed your code, And you could of just done this:

local SpawnPoint = { min = Vector(-100,-100,-100), max = Vector(100,100,100)}
local entss = ents.FindInBox(SpawnPoint.min,SpawnPoint.max)
for k,v in pairs(entss) do
if v:GetClass() == "prop_physics" then v:Remove()

In your ignorance you might have missed the part at the bottom of my post that said you could also use Ents.FindInBox …

I did say that you gave me the idea :3

Whoa, watch out, kids. We got a Lua king here. A script that probably took you five minutes to write is totally worth a copyright. Keep doing what you’re doing, don’t let anyone tell you otherwise. © – All rights reserved.

It is an effective bit of coding, only problem is, players with lesser understanding don’t understand why their creations vanish when they get to close to the spawn. How would I go about using a similar script to teleport players & their props to a nominated spot or distance from the spawn ?

instead of v:Remove() , do v:SetPos(Vector(x,y,z)

Thanking you guys so very much for you assistance and wisdom.

Just because I take pride in putting things I make under a license I wrote doesn’t make me a Lua king, It just makes me a wise person. When I put my script under my license, I removed everyone’s right to claim it as their own, as most people do. And to be honest, Every time I open N++, I have that as a predefined text. On a side note, you can’t reserve rights on what you just said ( the “© – All rights reserved” indicates that you intend to ) because it isn’t a trademark or an asset to your company. You also forgot to put your Name and the Year of copyright after then © logo.

Now let’s stop shit posting, the guy got his answer, let’s not turn this into a battle on whose got the biggest URL.

Where would someone call themselves a pedant? Only in this thread, ladies and gentlemen.

What are you on about still? I was saying that I was pedantic, not you.

Now now kittys… Let’s not get into a scrap now…