• Only press E to pickup weapon, lua error
    1 replies, posted
[CODE]hook.Add( "PlayerSpawn", "PickupTimeout", function( ply ) ply.PickupTimeout = CurTime() + 0.5 end ) hook.Add( "PlayerCanPickupWeapon", "NoPickup", function( ply, wep ) if ( ( ply.PickupTimeout or 0 ) < CurTime() ) then return false end end ) hook.Add( "KeyPress", "PressUse", function( ply, key ) if ( key == IN_USE ) then local tr = ply:GetEyeTrace() if ( ValidEntity( tr.Entity ) and tr.Entity:IsWeapon() and tr.Entity:GetPos():Distance( ply:GetShootPos() ) < 96 ) then ply.PickupTimeout = CurTime() + 0.5 ply:Give( tr.Entity:GetClass() ) tr.Entity:Remove() end end end )[/CODE] Can't figure it out. Here's the error. [CODE][ERROR] lua/autorun/weaponpickup.lua:12: attempt to call global 'ValidEntity' (a nil value) 1. v - lua/autorun/weaponpickup.lua:12 2. unknown - lua/includes/modules/hook.lua:82[/CODE] It also disables me from instantly getting the weapon I want by just left-clicking it.
Sorry, you need to Log In to post a reply to this thread.