'PrintMessage' (a nil value)

Trying to write something via weapon’s shared.lua
[lua]if( SERVER ) then
AddCSLuaFile( “shared.lua” )
end

if( CLIENT ) then
SWEP.PrintName = “Printing shit”
SWEP.Slot = 5
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end

SWEP.ViewModelFOV = 47
SWEP.ViewModelFlip = false

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.ViewModel = “”
SWEP.WorldModel = “”

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Ammo = “none”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Ammo = “none”

function SWEP:PrimaryAttack()
local ply = self.Owner
if ply.attackdelay == nil then
ply.attackdelay = 1
end
if ply.attackdelay == 1 then
PrintMessage( HUD_PRINTTALK, ply:GetName() … " clicked sumthing :O" )
self.Weapon:EmitSound(“buttons/button15.wav”)
ply.attackdelay = 0
timer.Simple(5, function()
ply.attackdelay = 1
end)
end
end

function SWEP:SecondaryAttack()
return false end[/lua]

and it says


:42: attempt to call global 'PrintMessage' (a nil value)

even if it works <.< how can I fix this?

It’s not a global function, it’s a function defined on the player object. Therefore, the syntax is


ply:PrintMessage("YOURMESSAGE")

Oh god why didn’t I think about that? Thanks.