Before I start I should say that I'm fairly new to programming. Currently trying to make a script that spawns the player at the same spot where he died, however whenever I run the script it gives me this error.
[ERROR] addons/aaa/lua/weapons/test.lua:9: attempt to index global 'ent' (a nil value)
Here is the code.
--Command
concommand.Add( "test_command", function( ply )
local hi = ply:GetPos()
ply:Spawn()
ent.ply:setPos (hi)
end)
(That's the entire script btw) If anyone could help me that would be greatly appreciated.
I assume you want to set position to the ply
variable.
concommand.Add( "test_command", function( ply )
local hi = ply:GetPos()
ply:Spawn()
ply:SetPos(hi)
end
)
From the docs, it should be SetPos
and not setPos
.