GetNWInt on Client (delay?)

Hey guys I’m having a problem with ‘GetNWInt’,

basically If I ‘LocalPlayer:GetNWInt(“Example”)’ on client it returns 0, aka It doesn’t update


local ply = LocalPlayer()
print(ply:GetNWInt("Example")) -- This will print '0' every time
if ply:GetNWInt("Example") != 0 then
    --stuff-- // This is not running ever


hook.Add("PlayerDeath", "Example_hook", function(vic, infl, ply)
    ply:SetNWInt("Example", ply:GetNWInt("Example")+1)

Are you sure you’re running the client code after the server has run?

The third argument of the PlayerDeath hook is the attacker. So you are setting the NWInt on the attacker, you should instead set it on the victim (the person who died) That is probably what you are trying to do, right?

I’m 99% sure.

I’ll just draw the number on my HUD just to see if it’s working at some point.

Nop, it’s not what I’m trying to do, I want the Attacker’s NWInt to increment.

Edit: code_gs was right. Basically I’m incrementing with a “PlayerDeath” hook and if I do a double kill it won’t show a different number on client because it first reads both playerdeaths on servers.
Is there any other solutions for this but timers?

Thanks in advance!

Your code looks fine serverside, just wait clientside before using

The only way to do it is with timers right?

You don’t have to, depends on when you want to use it

Honestly I would like to use it asap.

The problem is if I make a timer some computers are slower than others, I’m pretty sure 0.1s would be enough tho.

EDIT: What I said it’s kinda dumb.

Any suggestions tho?

I meant when on the client are you using it, in drawing a HUD?

Ah, no I’m using it to show the Value in a notification

If you use NW2Vars instead, you can use

Entity:SetNWVarProxy to see when it’s updated on the client.

Thanks for the info!

Also is it better to use NW2Vars over NWVars in all cases?

Thanks in Advance :slight_smile:

Yes, the original plan was for NW2Vars to replace NWVars, but it has seemingly been abandoned.

I made a search on NW2Vars, they would be great, do you know why didn’t they replace it the NWVars for NW2Vars yet?