Humanoid.HealthChanged odd behaviour

The HealthChanged event is fired by either the MaxHealth being changed and by the Health being changed, but in both cases returns only one value, being the Humanoid’s current health.

Due to this, setting a Humanoid’s MaxHealth and Health properties simultaneously will cause the event to fire twice, returning two different values. These conflicting values can affect anything using this event, including the Health CoreGui.

1. Does the bug happen 100% of the time?

2. If so, are there steps that reproduce the bug? Please list them in very high detail.

-- This assumes the Player variable has been defined local Humanoid = Player.Character.Humanoid Humanoid.MaxHealth = 200 -- Must be set first to take, but returns Humanoid.Health = 200 -- Make sure the Humanoid has full health

Note: In my test cases, the client seems to always recieve the events from Health being changed, then followed by MaxHealth being changed. This causes LocalScripts to receive the new value first (from Health being changed), then “update” the value to what was returned from MaxHealth being changed, lying to the script and giving it an incorrect reading. See video below

3. Where does the bug happen (www, gametest, etc)
This happens on production

4. Is it level-specific?

5. Would a screenshot or video help describe it to someone? If so, post one.

Since it’s hard to see what’s going on here, I’ll explain:

  1. I use admin commands to change my health from 100 to 200
  2. The server changes my MaxHealth and Health
  3. Client receives HealthChanged signal with value of 200 (from changing Health)
  4. Client receives HealthChanged signal with value of 100 (from changing MaxHealth)

6. For graphics bugs, it is sometimes helpful to know your system specs, especially graphics card.

7. When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.

8. Anything else that you would want to know about the bug if it were your job to find and fix it.
This isn’t entirely related to the bug, but I’d consider it helpful to make a change to the event and have it return the MaxHealth as well as the Health.

Change from:

return Humanoid.Health


return Humanoid.Health, Humanoid.MaxHealth
1 Like