We use cookies on this site to enhance your user experience

Displaying a Humanoid's Health and Name

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