pl/ply being a nil value?

I know this is REALLY dumb and I should know this but, how would I stop it from being a nil value

if IsValid(ply) then 


But isn’t not valid. Its showing as a Nil value and the script doesn’t work

You’re not giving us anything useful here to send you along with.

ply = player

function DropCurrentWeapon(ply)
         local Currentweapon = ply:GetActiveWeapon()

         local NewWeapon = ents.Create(Currentweapon:GetClass())

         local currentweaponclip1 = Currentweapon:Clip1()
         local currentweaponclip2 = Currentweapon:Clip2()


         NewWeapon:SetPos(ply:GetShootPos() + (ply:GetAimVector() * 30))

         ply.AllowWeaponPickupFix = 0




function PickupDelayFunc(ply)
         ply.AllowWeaponPickupFix = 1

if SERVER then

function AutoBindOnSpawn(ply)
         ply.AllowWeaponPickupFix = 1
         ply:ConCommand("bind z DropWeapon


function RePickupFix(ply,weapon)
         if ply.AllowWeaponPickupFix == 0 then return false end


ply is actually to something… right?

OP is a prime example of people that don’t deserve our help. He doesn’t even take the time to explain his problem properly, he didn’t initially post his code and we still haven’t even gotten an error from him.

But, thats all the information I could think of? Anything else you think would be needed. I really am happy for your help and I do try to post on Help threads also.

hook.Add(“InitPostEntity”, “Hello”, function()
– your code here

It helped me once with all the LocalPlayer() aka ply being nil.

I posted my error

[editline]13th September 2013[/editline]

Oh shit
No I didn’t
Really sorry D:

[ERROR] lua/autorun/dropweapon.lua:28: attempt to index local 'ply' (a nil value)
  1. unknown - lua/autorun/dropweapon.lua:28

Timer Failed! [Simple][@lua/autorun/dropweapon.lua (line 17)]


After I drop the gun and stand on it I get this error. It also stops me from picking up guns

I don’t understand how to use it. Do I put the hole code in the hook?

Yes, between the first and last line. Replace --your code here with your code.

Thanks, but now, as soon as you drop it, you pick it up again. The delay doesn’t seem to be working.

[editline]13th September 2013[/editline]

Also I have tried to stop people from dropping jb_hands but it doesn’t quite work. :frowning:

Your problem is here:

this isn’t how you make timers now.

timer.Simple(1.5,function() PickupDelayFunc(ply) end )