LUA - Serverside Variables stored & tied to each client?


There’s something I can’t quite wrap my head around, which is in Lua I would like it so that for example, each player has a certain variable which applies only to them, lets just say ‘Stamina’ tied to each of them individually, altered by the server individually, etc. I’d prefer to not have it be stored on the client as I feel it could be tampered with.

I have a feeling that tables can somehow do this, but I’m unsure.

You can just store the variable on the player.

Player.Stamina = 100

Adding onto what txike said, in case you don’t know this. All players are their own tables where you can store variables. Just make sure variable you store on the player is unique enough so that other addons don’t break your addon when they unknowingly overwrite it.

Oh cool, thanks for your help - does the same apply to NPCs and other entities? If not, how can I do it for those?

Yes each entity and NPC is its own table as well.

Could do.

ply:SetNW2Int("stam", 100)


What is a NW2Int?