NWInt's being reset.

When a player purchases an item the players Money Int is reset to whatever previous Int they had exactly 5 seconds after purchase, and the items NwInt is also set to whatever it previously was. I’ve scanned all of my code and nothing is even called every 5 seconds/5 seconds after purchase.

Also, I’ve even scanned through my code to see if “Money” or “Pistol” is called during the purchase time and it is not. This might be due to conflicting variable names but I doubt it considering I don’t have very much add-ons or other Gamemodes installed.

Purchase Function:
Input: ply,Pistol,50
[lua]
function BuyItem(ply,name,cost)

if(name == NULL or cost == nil) then return false end

if(GNWInt(ply,"Money") >= cost) then
	NWInt(ply,name,1)
	NWInt(ply,"Money",-cost)
	return false
end
ply:Notify("Can't afford that!")
return false

end
[/lua]

NWInt() and GNWInt():
[lua]
function NWInt(ply, type, int)
ply:SetNWInt(type, ply:GetNWInt(type) + int)
end

function GNWInt(ply, type, int)
return ply:GetNWInt(type)
end
[/lua]


[lua]
function BuyItem(ply,name,cost)

	if(name == NULL or cost == nil) then return false end
local themoney = ply:GetNWInt("Money")
	if(themoney>=cost) then
		ply:SetNWInt(name,1) /* I don't know what this is but I'm going to leave it, doesn't look useful though*/
		ply:SetNWInt(Money",themoney-cost)
		return true
	end
	ply:Notify("Can't afford that!")
	return false
end
[/lua]


Nope, that did not fix it.

Also, Line: 5 is for adding whatever item the player buys.

Try changing them up. This will make sure no other addon is conflicting.


[lua]
function BuyItem(ply,name,cost)

	if(name == NULL or cost == nil) then return false end
local themoney = ply:GetNWInt("Cash123")
	if(themoney>=cost) then
		ply:SetNWInt(name,1) /* I don't know what this is but I'm going to leave it, doesn't look useful though*/
		ply:SetNWInt("Cash123",themoney-cost)
		return true
	end
	ply:Notify("Can't afford that!")
	return false
end
[/lua]

Alright, I changed it to the following.

“Money134587”, “MoneyStatLyeol”, “MoneyStatPrivateRoleplay”, all of which did not work. I have no idea as to what could be causing this. The only function that is called multiple times on purpose is the Stamina system, I removed it and the players NWInt still reset.

Are you setting the Networked integers clientside? Because that would cause it. All of that code should be server side.

All of the code that I have posted in this topic is ServerSide.