Spawn ent, problem?

Hey I’m trying to spawn some things in top view and have this spawn function. In singleplayer this works fine, but in multiplayer it doesn’t spawn on mouse, Is there a fail? Or can anybody help me with this?

[lua]
if key == IN_DUCK and ply:GetNWBool(“IsInBirdEye”) == true then
local orig = ply:GetNWVector(“CameraPos”)
local ang = ply:GetCursorAimVector()
local trace = util.QuickTrace(orig, orig + ang * 1e9, ply)
if
ply:CanAfford ( 5 ) – can afford to buy, so just ignore
then
ply:RemoveMoney( 5 ) – then take money, so just ignore
Wall = ents.Create( “wall” )
Wall:SetPos(trace.HitPos)
Wall:Spawn()
else
ply:ChatPrint(“You don’t have enough Money !”)
end
[/lua]

[lua]
if key == IN_DUCK and ply:GetNWBool(“IsInBirdEye”) == true then
local orig = ply:GetNWVector(“CameraPos”)
local ang = ply:GetCursorAimVector()
local trace = util.QuickTrace(orig, orig + ang * 1e9, ply)
if ply:CanAfford ( 5 ) then
ply:RemoveMoney( 5 ) – then take money, so just ignore
Wall = ents.Create( “wall” )
Wall:SetPos(trace.HitPos)
Wall:Spawn()
else
ply:ChatPrint(“You don’t have enough Money !”)
end – This was missing
end
[/lua]

Oh my god that’s mangled. I fixed it (the messiness). What context is the code in?

Here:
[lua]
function team_2( ply )
ply:SetTeam( 2 )
ply:Spawn()

 function GAMEMODE:KeyPress(ply, key)
   
   if key == IN_RELOAD and ply:GetNWBool("IsInBirdEye") == false then    
        ply:SetNWBool("IsInBirdEye", true)    
        ply:SetNWVector("CameraPos", ply:GetPos() + Vector(0,0,600))    
    elseif key == IN_RELOAD and ply:GetNWBool("IsInBirdEye") == true then    
        ply:SetNWBool("IsInBirdEye", false)    
    end    
    
	
    if key == IN_USE and ply:GetNWBool("IsInBirdEye") == true then    				
   local orig = ply:GetNWVector("CameraPos")    
   local ang = ply:GetCursorAimVector()    
   local trace = util.QuickTrace(orig, orig + ang * 1e9, ply)
       if
       ply:CanAfford ( 7 )		-- can afford to buy,
       then
   	   ply:RemoveMoney( 7 )	-- then take money       
	   NPC = ents.Create( "zm_npc" )     
       NPC:SetPos(trace.HitPos)    
       NPC:Spawn()
	   else
	   ply:ChatPrint("You don't have enough Money !")
	end			   
 end    

   
    if key == IN_DUCK and ply:GetNWBool("IsInBirdEye") == true then
   local orig = ply:GetNWVector("CameraPos")    
   local ang = ply:GetCursorAimVector()    
   local trace = util.QuickTrace(orig, orig + ang * 1e9, ply)
   if
		   ply:CanAfford ( 5 )		
		   then
   		   ply:RemoveMoney( 5 )	
	   Wall = ents.Create( "wall" )     
       Wall:SetPos(trace.HitPos)
       Wall:Spawn()
else
			ply:ChatPrint("You don't have enough Money !")
		end		   
	end 
end

end
concommand.Add( “team_2”, team_2 )

[/lua]

Hope this can help, but its only in multiplayer, thats why im so confused :S

You’re defining a gamemode function in a console command. Put function GM:KeyPress() outside of the console command.

ok ill try that.

[editline]08:18PM[/editline]

That dident work, it still dosent spawn on my mouse.