Adding a Player Function.

Hey guys, can you tell me whats wrong with my code, i am trying to add a function which will be for all the players.
the error is that the function ‘SetJob’ isn’t recognised,

net.Receive(“changingjob”, function()
local ply = net.ReadEntity()
local id = net.ReadEntity()

That’s the correct way. But your code doesn’t make sense.
You’re supplying an entity in ply:SetJob( id ), but in your function you’re requesting a table.

yeah the id is the table, I am actually sending a table.

Then id should be net.ReadTable()

Done, still it doesn’t recognise SetJob as a function.

Ah, I see what your problem is. You’re calling this out of file right?

Rename the occurrences of ‘Player’ in the file to ‘PlayerMeta’

Meaning the first and second line of the pastebin

Works like a charm! :slight_smile:
Thanks mate.
one think though, do you know why it isn’t changing my model?

function Player:SetJob(tblKey)
print("trying to give my self")
for k,v in pairs(tblKey.weapon) do

And in addition after me defining this:

local Player = FindMetaTable('PlayerMeta')

everything works well BUT i am getting an error on the function Player:SetJob(tblKey) saying this:

[ERROR] gamemodes/****/gamemode/init.lua:15: attempt to index local 'Player' (a nil value)
  1. unknown - gamemodes/****/gamemode/init.lua:15

God, please, tell me you aren’t sending ply when using net.SendToServer()

Also possibly because it’s FindMetaTable( “Player” ) not FindMetaTable( “PlayerMeta” )

Also you are sending ID only, you should check for the table in your jobs tbl.
Also since when is ID an entity?

Yeah fixed it.
Its all good now, but for some reason the model isn’t being set up on my character.
I printed the Table and its a string… anyone has any clue why it isn’t setting my model?
this is my code realted to it:

	self:SetModel(tostring( tblKey.model ))
		for k,v in pairs(tblKey.weapon) do

Try setting model after spawn?

works thanks.