PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

NameDisplayDistance

Humanoid

float

The NameDisplayDistance property is a number used in conjunction with the Humanoid's Humanoid/DisplayDistanceType property to control how far a humanoid’s name can be seen from.

The DisplayDistanceType property is to one of three values using the Enum/HumanoidDisplayDistanceType enum.


DisplayDistanceType set to “None”##

When a humanoid’s DisplayDistanceType is set to None, its name 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 name is dependent upon the NameDisplayDistance 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 NameDisplayDistance, then the humanoid’s name will not be shown to the viewer.


DisplayDistanceType set to “Subject”##

When a humanoid’s DisplayDistanceType is set to Subject, the visibility of its name is dependent upon the value of the humanoid’s own NameDisplayDistance.

If the distance between the character models of the viewing player and the humanoid is outside the range of the humanoid’s NameDisplayDistance, then the humanoid’s name will not be shown to the viewing player.



Code Samples


Displaying a Humanoid's Health and Name

This example demonstrates how to set a Humanoid's Humanoid/DisplayerDistanceType, Humanoid/HealthDisplayDistance, and 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