Quick Question

Hey, I’m working on a quick thing for DarkRP ( Sigh, I know ), and I am fairly new to Lua, so I’m getting a basic error. I’m guessing it’s just an issue with the placement of some lines of the code.

I’m getting:


attempt to call global 'LocalPlayer' (a nil value)

Here’s my code: [lua]require(“datastream”)
if SERVER then
AddCSLuaFile(“shared.lua”)
end

if CLIENT then
SWEP.PrintName = “PickPocket”
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
end

SWEP.Base = “weapon_cs_base2”

SWEP.Author = “MOOcow”
SWEP.Instructions = “Left click to pick pockets”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.IconLetter = “”

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.AnimPrefix = “rpg”

SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “”

if CLIENT then
SWEP.FrameVisible = false
end

function SWEP:Initialize()
self:SetWeaponHoldType(“normal”)
end

function SWEP:Deploy()
if SERVER then
self.Owner:DrawViewModel(false)
self.Owner:DrawWorldModel(false)
end
end

function SWEP:PrimaryAttack()

self.Weapon:SetNextPrimaryFire(CurTime() + 15)

local trace = LocalPlayer():GetEyeTrace()
local ent = LocalPlayer():GetEyeTrace().Player

if not ValidEntity(trace.Player) then
	return
end

if self.Owner:EyePos():Distance(trace.HitPos) < 65 then
	trace.Entity:AddMoney( math.random( 10, 500 ))
end

self:SetWeaponHoldType("pistol")
timer.Simple(0.2, function(wep) if wep:IsValid() then wep:SetWeaponHoldType("normal") end end, self)

if CLIENT then return end

if self.Owner:EyePos():Distance(trace.HitPos) < 65 then
	trace.Entity:AddMoney( math.random( 10, 500 ))
end

end[/lua]

SWEPs are shared, use self.Owner instead.