0

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.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
beepandrew
  • 11
  • 1
  • 4

1 Answers1

1

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.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183