Im really new to Gmod Lua and I wanted a script that can set loot spawns so I found one and I ran it after modifying it to how I liked it and I get the error in the console:
[ERROR] lua/new.lua:8: Tried to use a NULL entity!
- SetPos - [C]:-1
- unknown - lua/new.lua:8
Timer Failed! [Spawnitem][@lua/new.lua (line 13)]
And here’s my code:
itemsTable = {“item_healthkit”, “sent_siku_crate”, “item_ammo_357”, “item_ammo_ar2”, “item_ammo_ar2_altfire”, “combine_mine”, “item_ammo_crossbow”, “item_healthvial”, “item_ammo_pistol”, “item_rpg_round”, “item_box_buckshot”, “item_ammo_smg1”, “item_battery”, “weapon_bfg_beta_spas”, “weapon_bfg_assasin_pistols”, “weapon_bfg_hmg”, “weapon_bfg_iceaxe”, “weapon_bfg_oicw”, “weapon_bfg_mp7”, “weapon_bfg_smg2”, “weapon_bfg_hl2_sniper”, “weapon_bfg_ar1”}
local poses = {Vector(228,134,135), Vector(1337,1337,1337), Vector(666,666,666)}
local itemstospawnpertime = 2
local timebetweenspawns = 5
function DoSpawnItem()
for i = 1, itemstospawnpertime do
local item = ents.Create( table.Random( itemsTable ) )
item:SetPos( table.Random(poses) )
item:Spawn()
end
end
timer.Create(“Spawnitem”, timebetweenspawns, 0, DoSpawnItem)
I can give more details when needed.