Attempt to index global 'CORPSE' a nil value.

I’m getting a “Attempt to index global ‘CORPSE’ a nil value.” error with my store code. I didn’t make it myself, but here is the code snippet that is erroring:
[lua]
– Send a usermessage to client containing search results
function CORPSE.ShowSearch(ply, rag, covert, long_range)
if not IsValid(ply) or not IsValid(rag) then return end
if !rag.searched then
rag.searched = true
ply:AddXP(VXP.XPForIdentify)
end
if rag:IsOnFire() then
LANG.Msg(ply, “body_burning”)
return
end
[/lua]
I’m not quite sure what the coder has done wrong there? I should, but I just don’t. Help would be appreciated.

It’s nothing wrong with this function, except that CORPSE is not defined or whatever defines CORPSE is broken. Where is it getting CORPSE from?

It’s coming from corpse.lua, from TTT.

The only part added is:
[lua]
if !rag.searched then
rag.searched = true
ply:AddXP(VXP.XPForIdentify)
end
[/lua]
Which means there must be something wrong with that.

What’s the exact error? It could be originating from somewhere else.

http://puu.sh/67Ty6.png

It doesn’t actually have a noticeable effect on the addon, it just gets really annoying when it is constantly spammed in the console log.

do CORPSE = CORPSE or {} at the start and see what changes?

Thanks mate! Worked a charm!

http://puu.sh/67USg.png