Problem with custom entity

(Old problem/Removed)________________________________________________________________________

Okay onto the unsolved problem:

Timer Error: …tstand\entities\entities\zombie_spawn_point\init.lua:35: attempt to index global ‘self’ (a nil value)
Timer Error: …tstand\entities\entities\zombie_spawn_point\init.lua:24: attempt to index local ‘tr’ (a nil value)

Code:

timer.Create( “ZombieSpawnTime”, 15, 0, function( tr, ent )

– local tr = self:GetPos()

   local percent = math.random(1,100) 
	 
	 if percent <= 50 then

local ent = ents.Create( “npc_zombie” )

ent:SetPos( tr.HitPos )--------24
ent:Spawn()
ent:Activate()

end

end )

timer.Create( “ZombieSpawnTimer”, 15, 0, function( tr, ent )
local tr = self:GetPos()-----------35

     local percent = math.random(1,100) 
	 
	 if percent <= 80 then

local ent = ents.Create( “npc_fastzombie” )

ent:SetPos( tr.HitPos )
ent:Spawn()
ent:Activate()

end
end )

Any ideas?

EDIT: Bump, shamelessly!

You missed a comma between “ZombieSpawnTimer” and 15:wink:

Well i did post it in the noob section. XD
BUMP

Bumpppppppp

Don’t use this thread for a new question, I almost ended up ignoring it.

" function( tr, ent ) " Should just be " function() "

Because timer.Create will not pass any functions through unless you tell it to. And self is not defined. It would help us a lot if you showed us the whole file.

Lua tags please