HealthDisplayDistance is a number used in conjunction with the
Humanoid/DisplayDistanceType property to control how far a humanoid’s health bar can be seen from in studs.
The DisplayDistanceType property is to one of three values using the
DisplayDistanceType set to “None”##
When a humanoid’s DisplayDistanceType is set to None, its health bar will never be visible to anyone under any circumstances.
DisplayDistanceType set to “Viewer”##
When a humanoid’s DisplayDistanceType is set to Viewer, the visibility of its health bar is dependent upon the HealthDisplayDistance of the player viewing it.
If the distance between the character models of the viewer and the humanoid is outside the range of the viewer’s HealthDisplayDistance, then the health bar will not be shown to the viewer.
DisplayDistanceType set to “Subject”##
When a humanoid’s DisplayDistanceType is set to Subject, the visibility of its health bar is dependent upon the value of the humanoid’s own HealthDisplayDistance.
If the distance between the character models of the viewing player and the humanoid is outside the range of the humanoid’s HealthDisplayDistance, then the health bar will not be shown to the viewing player.
Displaying a Humanoid’s Health and Name
This example demonstrates how to set a
Humanoid/NameDisplayDistance properties. These properties determine how a humanoid’s healthbar and name are rendered for a player.
First, we change the DisplayDistanceType to Viewer using
Enum/HumanoidDisplayDistanceType. When set to viewer, the humanoid’s Name and healthbar will be displayed based on the distance settings of the humanoid viewing them.
Then, the humanoid’s HealthDisplayDistance is set to 0. Setting the property to 0 hides the healthbar completely. It is not displayed at any distance.
Finally, the humanoid’s NameDisplayDistance is set to 100. This means that the humanoid’s name will be visible to other humanoid’s within 100 studs.
This example should work as expected when placed inside a
Script that is a child of the humanoid.
local humanoid = script.Parent humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.Viewer humanoid.HealthDisplayDistance = 0 humanoid.NameDisplayDistance = 100