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…
local pos = spawnpos:GetPos()
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.

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

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()
npc_count = npc_count + 1

timer.Create(“ZombieSpawnTimer”, 1, 0, SpawnZombie)

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.