I am trying to get currentoxygen to go down by 1 per second when the dive boolval is true and go up 1 per second when dive boolval is false. once max oxygen is ahieved, incrementing will stop. I have a region3 area (using ZonePlus V2) that toggles the dive boolval off and on for the player when they enter and exit. I probably cannot do this within the leaderboard, but it is where i decided to try. The local function at the bottom is what im working at. Thank you in advance.

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
 
	local money = Instance.new("IntValue")
	money.Name = "Money"
	money.Value = 0
	money.Parent = leaderstats
 
	local garbage = Instance.new("IntValue")
	garbage.Name = "Garbage"
	garbage.Value = 0
	garbage.Parent = leaderstats
 
	local bagsize = Instance.new("IntValue")
	bagsize.Name = "BagSize"
	bagsize.Value = 2
	bagsize.Parent = leaderstats
	
	local currentoxygen = Instance.new("IntValue")
	currentoxygen.Name = "CurrentOxygen"
	currentoxygen.Value = 10
	currentoxygen.Parent = leaderstats
	
	local maxoxygen = Instance.new("IntValue")
	maxoxygen.Name = "MaxOxygen"
	maxoxygen.Value = 20
	maxoxygen.Parent = leaderstats
	
	local multiplier = Instance.new("IntValue")
	multiplier.Name = "Multiplier"
	multiplier.Value = 1
	multiplier.Parent = leaderstats
	
	local divestatus = Instance.new("BoolValue")
	divestatus.Name = "DiveStatus"
	divestatus.Value = false
	divestatus.Parent = leaderstats
	
		
	
	local function oxygensystem(currentoxygen, maxoxygen, divestatus)
		local air = script.Parent:GetChildren("CurrentOxygen")
		local tank = script.Parent:GetChildren("MaxOxygen")
		local dive = script.Parent:GetChildren("DiveStatus")
		
		if dive.Value == true and air.Value < tank.Value then
			air.Value = air.Value - 1
		else if dive.Value == false then
				air.Value = air.Value + 1
				
			end
		end
		
	end
end