Tool = script.Parent function onEquippedLocal() local humanoid = Tool.Parent:FindFirstChild("Humanoid") humanoid.MaxHealth = humanoid.MaxHealth + 25 humanoid.Health = humanoid.MaxHealth end function onUnequippedLocal() local humanoid = Tool.Parent:FindFirstChild("Humanoid") humanoid.MaxHealth = humanoid.MaxHealth + 50 humanoid.Health = humanoid.MaxHealth end Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal)
basically when you equip your tool it gives you 125 maxhealth but when you unequip it doesnt make your maxhealth go up by 50
When a player unequips a tool, it goes into the player's Backpack, it does not remain inside the character. So, inside your unequip function, Tool.Parent
is actually the backpack, not the character.
Tool = script.Parent function onEquippedLocal() local humanoid = Tool.Parent:FindFirstChild("Humanoid") humanoid.MaxHealth = humanoid.MaxHealth + 25 humanoid.Health = humanoid.MaxHealth end function onUnequippedLocal() local Player = Tool.Parent.Parent local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") Humanoid.MaxHealth = Humanoid.MaxHealth + 50 Humanoid.Health = Humanoid.MaxHealth end -- Use 'Connect' as 'connect' is deprecated. Tool.Equipped:Connect(onEquippedLocal) Tool.Unequipped:Connect(onUnequippedLocal)