Use ENT reference in a net receive hook

Is there a way to, as the title says, use an ENT reference in a net recieve hook?

I’m sorry if it doesn’t make sense. I don’t know quite what I’m asking, to be honest.

What I have is something like


serverside, and then clientside, I have

net.Receive( "Message", function()

I want to use NetworkedVars, and get them in the netmessage, but ENT/self isn’t defined there. Any idea how I would do that, or, not using netmessages, another way?

(I have actual code if that’s actually needed, but it’s messy and looks bad, and this is just a general idea, not specific to that code)

Net.WriteEntity. Just send the entity in the net message.

No, you gotta send EntIndex and get the entity using Entity()

I tried


, and it gave me

[ERROR] addons/tests/lua/entities/test/init.lua:26: bad argument #2 to 'WriteInt' (number expected, got no value)

EDIT: Nevermind, that was just me forgetting how net ints work. Sorry.