DefaultOverheads
I won’t spend as much time as usual explaining things or decorating the post, since my resources don’t generate much interest most of the time.
This system looks and behaves exactly like the default Roblox overhead (display name), to a T, I checked every pixel and (I think) every scenario. But it has all the benefits of having a Gui you can access: rich text (enabled by default), changing colors, adding gradients, and so on. A bonus is that NPC overheads hide properly (when obstructed), while the default ones don’t.
DOWNLOAD: DefaultOverheads.rbxm (14.8 KB)
I still can’t publish packages to the marketplace for some reason, it is what it is, you can “watch” the topic if you’re interested in updates.
I made it very out-of-the-box, you can just put the ModuleScript inside ServerScriptService and it will replace all default overheads. It also does cleanup in regard to the Guis, but it does not clean up Player/Character connections, which you should be destroying yourself.
I will explain only basic usage, for anything beyond that feel free to ask:
That’s the script of interest.
You may, of course, require it from elsewhere if needed.
Here is a basic example:
local DefaultOverheads = require(script.Parent)
DefaultOverheads.OnAdded:Connect(function(OverheadGui)
if not OverheadGui.Player then -- NPC
return
end
local DisplayName = OverheadGui:GetTag('DisplayName')
DisplayName.Text = '⭐' .. DisplayName.Text .. ' ⭐'
-- an example of connecting to the Player
local Level = OverheadGui:AddTag('Level', '')
local leaderstats = OverheadGui.Player:WaitForChild('leaderstats') -- if you're sure it will be added
leaderstats.Level.Changed:Connect(function(level)
Level.Text = 'level: ' .. level
end)
Level.TextSize = 32
Level.Text = 'level: ' .. leaderstats.Level.Value
-- an example of connecting to the Character
local Hurt = OverheadGui:AddTag('Hurt', '')
local Humanoid: Humanoid = OverheadGui.Character:WaitForChild('Humanoid') -- if you're sure it will be added
Humanoid.HealthChanged:Connect(function(health)
Hurt.Text = health < Humanoid.MaxHealth and 'HURT' or ''
end)
Hurt.FontFace = Font.fromName('Jura', Enum.FontWeight.Bold)
Hurt.TextColor3 = Color3.new(1, 0.25, 0.25)
Hurt.Text = Humanoid.Health < Humanoid.MaxHealth and 'HURT' or ''
end)
To see the results (without having to invite someone else), either find the BillboardGui inside your Character, and clear the PlayerToHideFrom
property, or add the overhead to a Dummy/NPC.
And here is a basic overview of the two modules (server-side that is):
DefaultOverheads
function DefaultOverheads.Add(Character: Model, Adornee: BasePart): OverheadGui
Creates a new OverheadGui. This is done automatically for all Player Characters, you only need to use it for NPCs. Adornee
is required for now, use the Head for default look. It doesn’t have to be an R15 or R6 Character/Model though, nor does it need to have a Humanoid, it can be anything.
returns OverheadGui
object (more on that below), not the BillboardGui Instance
function DefaultOverheads.Get(Character: Model): OverheadGui?
returns OverheadGui
object of a Character/Model (if it exists); again, not the BillboardGui Instance
function module.OnAdded:Connect(func: (OverheadGui: OverheadGui) -> (), ignoreExisting: true?): Connection
OnAdded is a fake signal, just a holder for :Connect
to which you provide a function which will be called every time a new OverheadGui
is created. The function will also be called for every existing OverheadGui
unless ignoreExisting
is true
. To avoid the possibility of missing any of the automatically created ones, don’t use this unless you know why you’re using it.
returns a fake connection that can be :Disconnect()
-ed
OverheadGui
OverheadGui.Character: Model
OverheadGui.Player: Player?
Self-explanatory. These are there so you don’t have to combine this module with other code too much, but can instead access the Character/Model and Player (if any) directly, for the purpose of adding and modifying tags.
function OverheadGui:AddTag(name: string, text: string, index: number?): TextLabel
Creates a new “tag” - that is, a TextLabel which you can then modify directly.
name
is used as an identifier. If a tag with the same name already exists, it will be removed; the new one will inherit it’s position (layout order)(if index
is not provided) but nothing else. Sometimes you might want this, but most of the time you’ll want to modify the existing tag.
text
is self-explanatory
index
is an optional number to push the tag to a specific position (vertically). If not provided, the tag will go on top of the existing ones. Tags are indexed bottom-to-top.
A “DisplayName” tag is created by default for Player Characters and NPCs alike. It’s text will be either the Player.DisplayName, or the name of whatever Instance you used to create the OverheadGui
if there is no associated Player.
returns TextLabel
function OverheadGui:GetTag(name: string): TextLabel?
Primarily for modifying the premade “DisplayName” tag.
returns TextLabel (if it exists)
To remove a tag you can :Destroy()
it, it’s safe. :Destroy()
-ing the BillboardGui is also safe.
That's it! That's the basic overview. There are more things to be said, I haven't even mentioned the client side of things, but the average user wouldn't be interested. If you are, again: ask away.
There are also things that are tucked away (there, but won’t show up in auto-complete) so the average user won’t be tempted. You can look through the code (or ask) if you want to access something specific.
As for upgrades, client options are one possibility - e.g. toggling visibility for all overheads, as well as your own, setting the display distance, adding a scale multiplier, and so on. Recreating the health bar is also an option, integrating images, adding helper functions for gradients…
If there’s enough interest in the community, I can do some/all of these things, and/or other things… whatever is requested most.
Almost forgot… performance… should be fine. I got an average of ~1ms for 64 dummies, most of which were in range (which then requires a raycast).