SetPos works but not GetPos?

Im trying to use this code:
spawnpos being an entity selected out of a table using table.Random
SetPos works just fine but when i try getpos…
[lua]
local pos = spawnpos:GetPos()
[/lua]
I get this error
Timer Error: [gamemodes\zombie\gamemode\init.lua:33] attempt to call method ‘GetPos’ (a nil value)
Im using a timer to call this function, thats why the timer error.

Are you sure that you have added all arguments to the timer function?

Why don’t you give us the actual code then? Speeds up the process.

EDIT: Sorry, bad reading.

[lua]
hook.Add(“InitPostEntity”, “lol”, function()
spawnposes = {ents.FindByClass(“info_player_start”)}
end)

function SpawnZombie()
if(npc_count > 41) then return end;
local spawnpos = table.Random(spawnposes)
local zombie = ents.Create(“npc_zombie”)
local pos = spawnpos:GetPos()
local angle = spawnpos:GetAngle()
zombie:SetPos(pos)
zombie:SetAngle(angle)
zombie:Spawn()
npc_count = npc_count + 1
end

timer.Create(“ZombieSpawnTimer”, 1, 0, SpawnZombie)
[/lua]

That would be all the code surrounding that bit.

Remove the ‘{’ and ‘}’ around ents.FindByClass(“info_player_start”) on line 2. ents.FindByClass returns a table and doesn’t need to be placed inside another.

That fixed it, thanks

You’re welcome.