Issues with meta tables

In cl_init I call LocalPlayer():GetRace() and it returns a nil value. Why is that? Did I set up my meta tables correctly for Gmod13?

The code there is fine, post your cl_init.lua

Possibly because your not setting race.

[lua]
local meta = _R.Player
function meta:SetRace(race)
print("set race called for " … self:Nick())
self:SetNWString(“Race”, race)
end

function meta:GetRace()
print("get race called for " … self:Nick())
return self:GetNWString(“Race”) or “Human”
end
[/lua]

I have the race being set in a file called deathknight.lua. I can confirm that SetNWString is working: http://pastebin.com/aUiMU20g

But calling back using GetRace just does not seem to work

Here is where I SetRace:

Here is where I GetRace:

DONT mind the __toString() it doesnt work ;3
just some scrap i left thar.

Are you calling GetRace on SERVER or CLIENT. And where is GetRace located(SERVER CLIENT OR SHARED?)?

That GetRace you saw that was commented out was from cl_init.lua

It doesn’t work because your not using it right from what I see here in front of me.

Okay it’s removed. Don’t worry about the tostring crap that was there.

I know that bit :slight_smile: I had just left it there

And where is GetRace function located on(in) a server (file) or on(in) client (file)

GetRace was created in init.lua

So what you need to do is the following. Removed it and paste it in a file that’s loaded by client and server. Or just create a file thats loaded by client and server. Your trying to use a funciton that doesn’t exist on the client.

So I can take http://pastebin.com/hf9e0DD4

And put it in, say shared.lua?

Yes, but I’d leave SetRace function on server.

Alright it’s all working great. Thanks for your help Aide!