ply:SetNWInt() resets after a while

Okay, so in my addon, I want to set the networked integer “MLevel_level” on a player during initial spawn, this works. I want to change the variable, this works. However, after a while the variable resets to 0


function MLevel_PlayerInit(ply)	
  ply:SetNWInt("MLevel_level", 0)
  ply:SetNWInt("MLevel_skill", 0)
hook.Add("PlayerInitialSpawn", "MLevelInitializePlayer", MLevel_PlayerInit)


local MLevel_SkillList = {"level","skill"}

// Admin Commands /////////////////////////////////////////////////////////////////////////////////////////////////////////

local function MLevel_IsSkill(skill)
	for k,v in pairs(MLevel_SkillList) do
		if v == skill then return true end
	return false

local function MLevel_SetPlayerStat(ply, cmd, args)
	if not ply:IsAdmin() then return end
	local target 	= player.GetAll()[tonumber( string.Trim( args[1]))]
	local skill		=	string.Trim( args[2])
	local amount 	= tonumber(string.Trim(args[3]))
	if not MLevel_IsSkill(skill) then ply:ChatPrint("Invalid Skill Set") return end
	local past = target:GetNWInt("MLevel_level")

	target:SetNWInt("MLevel_"..skill, amount)
	print("Your level was "..past..", now it's ""MLevel_level"))
concommand.Add("MLevel_Admin_SetPlayerStat", MLevel_SetPlayerStat)

// Admin Commands /////////////////////////////////////////////////////////////////////////////////////////////////////////

In Testing, after first spawning, it’s 0

After setting my level to 50 and waiting ~10 seconds, I find it was reset to 0 again

Is this on a windows sever or linux server?

If it’s windows then any time you make a change to your code it will auto reload and the data you had before you saved will be lost.

It looks like you’re also trying to make a leveling system; here’s a nice tutorial for uou

It’s a windows server, but the data resets without making any changes to the code. I will look at that tutorial but I still need help.

Your command is running on the client, not the server, which is setting your nwint clientside. It will automatically revert to the server value periodically when you change it that way.