SetNWInt not working

another car problem here.

LocalPlayer():GetVehicle():SetNWInt( “fuel”, LocalPlayer():GetVehicle():GetNWInt( “fuel” ) - (math.floor((LocalPlayer():GetPos() - LocalPlayer().oldLoc):Length()/( math.abs( CurTime() - LocalPlayer().updatedTime )17.6))(CurTime() - LocalPlayer().updatedTime)) )

using this to find the speed of my car and take away the speed of your car per second. I get no errors and retrieving the value always returns the initial set value. what did i do this time?

This isn’t a direct answer to your question, and I could be wrong, but I think you would have better luck looking into the velocity of the object to determine its speed.

Also, layering that many functions is usually a horrible idea. It’s much cleaner and more efficient to get your variables first, then do math with them.

The massive equation you have now is prone to way too many issues.

Keep in mind that using GetNWInt (or any GetNW) takes a default variable in case fetching fails, and you don’t have one in your function. Not all errors are returned in console, so I would be very weary of trusting that the equation actually works under ideal circumstances.

I made a speedometer separate that works, i just took the code form it. I’ll try and put everything into variables.

how’s this?
[lua]veh:SetNWInt( “fuel”, veh:GetNWInt( “fuel” ) - ( LocalPlayer().CurSpeed*(CurTime() - LocalPlayer().updatedTime)) )[/lua]

You should be using SetNWInt on the serverside, I see you used LocalPlayer() which indicates clientside.

If you’re trying to set the value from the client and then retrieve it on the server, it doesn’t work like that. If you set it from the server then it will change on the server and on the client, if you set it from the client then it will just change on the client.

I ended up using net library and timers to get it done, but thank you guys for your help