Script won't save value update

Hello! I recently made a functional character heat system. Basically, its a heat system that reduces its value every 9 seconds, and if it hits 0, then they die. But, whenever a event is triggered, it adds heat to the value. However, whenever the 9 seconds is passed, it reverts the value to before they gained it. My scripter doesn’t have enough experience on this stuff, so I came here as a last resort. If you could figure out the problem, that would be great!

Script that adds heat whenever the event is fired: (Localscript in StarterGui)

local INCREASE_AMOUNT = 8

game.Players.PlayerAdded:Connect(function(Player)

local Heat = Instance.new("IntValue", Player)

Heat.Name = "Heat"

Heat.Value = 100

end)

local Player = game.Players.LocalPlayer

game.ReplicatedStorage:WaitForChild("Heat").OnClientEvent:Connect(function()

Player.Heat.Value += INCREASE_AMOUNT

end)

Script that decreases the amount over time: (Script in ServerScriptService)

local DECREASE_FREQUENCY = 1
local DECREASE_AMOUNT = 2
local INCREASE_AMOUNT = 8

game.Players.PlayerAdded:Connect(function(Player)
	-- run this code.
	
	local Hunger = Instance.new("IntValue", Player)
	Hunger.Name = "Heat"
	Hunger.Value = 100 -- how much hunger you will have.
	
	Player.CharacterAdded:Connect(function()
		Hunger.Value = 100 -- resets every time your character respawns.
	end)
	
	while wait(DECREASE_FREQUENCY) do
		-- run the code in here.
		
		if Hunger.Value <= 0 then
			Player.Character:BreakJoints()
		else
			Hunger.Value -= DECREASE_AMOUNT
		end
	end
end)

Script that updates the bars size: (Localscript located in a Screengui in StartGui)

local Player = game.Players.LocalPlayer
local Heat = Player:WaitForChild("Heat")

local GUI = script.Parent
local BarExterior = GUI.Bar
local BarInterior = BarExterior.Bar

local function UpdateHeat()
	-- update the hunger.
	
	local CurrentValue = Heat.Value
	local Formula = math.clamp(CurrentValue/100, 0, 1)
	
	BarInterior:TweenSize(UDim2.new(Formula, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.15, true)
	
end

UpdateHeat()
Heat.Changed:Connect(function()
	UpdateHeat() -- call function.
end)

I hope that’s two different scripts, because you don’t want to be using player added and local player back to back in a case like this.

It looks like your perform stems from a misunderstanding of the client server boundary. For almost anything that is changed in a LocalScript, the server won’t see the changes. So when heat is added by the LocalScript, it gets ignored. You will need to look up a tutorial on RemoteEvents to fix it.