attempt to index global 'chat' (a nil value)

The error is:
“weapons/hl2_combo_fists/shared.lua:151: attempt to index global ‘chat’ (a nil value)”
The code is: (Line 151 is chat.Addtext)
[lua]
function SWEP:Reload()
if (CurTime() < self.ProvokeTime) then return end
self.ProvokeTime = (CurTime() + 2)
–self.Weapon:EmitSound(self.Provoke[math.random(#self.Provoke)])
local plr = self.Owner
chat.AddText(plr, Color(100,255,100), "Your class is: " … tostring( plr:Team() ) )
end
[/lua]

Yes, this is from the HL2 Combo Fists. I’m the lua modder for BestSeriousRP. We give credit.

Btw, I only added:
[lua]
local plr = self.Owner
chat.AddText(plr, Color(100,255,100), "Your class is: " … tostring( plr:Team() ) )
[/lua]
Also, it prints to chat, (exactly as it should) yet I still get that error.

Someone want to tell me what I’m doing wrong? I’ve got no idea.

[editline]10:41PM[/editline]

I also followed the wiki to point.

It’s being run from the server. IIRC, SWEP:Reload is shared. Just wrap the chat.AddText with an “if CLIENT” statement.

Sweet, Thanks!
Testing now.

[editline]10:54PM[/editline]

Dude, you rock. That worked perfectly. Now to move onto the real editing.