Need Help with Script [Need Help]

Hi I was making armor system using tools.
I ran into a problem when I equip one armor last ones maxhp + stays
I wanna remove the last hats/armors hp buff/hp+

tools script:

local st = game:GetService("ServerStorage")
local rs = game:GetService("ReplicatedStorage")
local tool = script.Parent
local Handle = script.Parent:FindFirstChild("Handle")

function onActivated()
	if not tool.Enabled then
		return
	end

	wait(1)
	
	local h = tool.Parent:FindFirstChild("Humanoid")
	if (h ~= nil) then
		if h.Parent:FindFirstChild("helm") then
			h.Parent.helm:destroy()
		end
		local hat = st.Fire.Helm.FlameG["helm"]:Clone()
		hat.Parent = h.Parent
		h.WalkSpeed = 4
		h.JumpHeight = 0
		h.MaxHealth = h.MaxHealth + 25
		h.Health = h.Health + 25

		wait(.5)
		h.WalkSpeed = 16
		h.JumpHeight = 7.2
	else
		return
	end
	
	wait(1)
	
	--script.Parent:Remove()
	
end

function onEquipped()

end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

Video:

I noticed in the video that your were manipulating objects in the explorer while you were still on the client side, try manipulating them on the server side and see if that works.

I checked it on server side nothing changed
I wanna make it so when I equip helm or any other armor I don’t want hp to stack if I equip the same time of armor

server side:
https://gyazo.com/a30d794f7f3ac6b170426b2db83f82c2

client side:
https://gyazo.com/e0296dc56c475d93272392d68c03e466

(note: I would send the video but devforum doesn’t allow more than 10mb videos and I am slow doing stuff in roblox studio)

In your script, try creating a function that sets the health back to what you want it to be when you change the tool equipped. The script that is shown above, it has a line that adds 25 to the MaxHealth but is does not remove the 25 when the tool is changed.

what do you mean by that because I have other type of armor like this and not all helmet will give me 25+ hp so I cant just -25

ok… Define ‘same type of armor’.

nvm I fixed it all I had to do is add

			local mhp = h.Parent.helm.hp.Value
			h.MaxHealth = h.MaxHealth - mhp
			h.Parent.helm:destroy()

I added a value to hat which tells how much hp it give/takes away and it works

That is what I was trying to tell you… remove the health that it added when changing the tool.

I thought you meant to add a function to the tool when equipping a different tool to change my hp