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)
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
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.