I want to achieve that the text labels text is the users rank and then the users username after the role. And a space between splitting the message.
I have tried using overhead.Username.Text = rolename .. " " .. plr.Name but it doesn’t work. local rolename = plr:GetRoleInGroup(5813923) is how I am defining the role name variable.
I am trying to make it similar to this:
I have searched for a similar problem but didnt find one.
btw I didnt forget the ends, its just that some confidential info comes next as im using http service and some account tokens after.
Also What I mean with “it dosent work” is that it dosent show me any errors nor dosent it show me the overhead. It just sets the text label to my username without the rank.
rolename prints out the rank of the user in a string format.
The billboardgui isnt parented to the head, its parented to the humanoidrootpart though im setting the billboardguis adornee to attach which is in the characters head.
Here you go:
local overhead = script.Overhead:Clone()
local attach = Instance.new("Attachment")
attach.Name = "UIAttachment"
local chara
local player
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
attach.Parent = char.Head
attach.Position = char.Head.Position * Vector3.new(0,0.03,0)
overhead.Parent = char:WaitForChild("HumanoidRootPart")
overhead.Adornee = attach
chara = char
player = plr
local rolename = plr:GetRoleInGroup(5813923)
print(rolename)
if player.TeamColor == BrickColor.new("Really blue") then
overhead.Division.Text = config.JediOrderText
overhead.Division.TextColor3 = config.JediOrderColor
overhead.Username.Text = rolename .. " " .. plr.Name
overhead.Rank.Text = player:GetRoleInGroup(5813923)
I recommend parenting the BillboardGui to the player’s head since it would make it easier to display and eliminates the need for an attachment.
Here’s how I usually handle BillboardGui ranks and Text:
local players = game:GetService("Players")
-- It's better to make this a separate function to make it easily re-usable
local function onCharacterAdded(char)
local billboardGui = BillBoardGui:Clone() -- copy the actual BillboardGui
local head = char.Head
local username = billboardGui.username -- the place where the player's Role and Username will be displayed
local player = players:GetPlayerFromCharacter(char) -- Get the Player Instances from the provided character (since we don't have it anymore)
local rolename = player:GetRoleInGroup(5813923)
billboardGui.Adornee = head
billboardGui.StudsOffset = Vector3.new(0, 1.5, 0) -- This sets the BillboardGui 1.5 studs above the player's head
billboardGui.Parent = head
username.Text = `{rolename} {player.Name}` -- This displays the player's role and username using string interpolation
-- read more here: https://devforum.roblox.com/t/string-interpolation-available-for-studio/2127058
end
player.PlayerAdded:Connect(function(player)
if player.Character then -- if the player's character exists before the event fired
onCharacterAdded(player.Character) -- call the function by default
end
player.CharacterAdded:Connect(onCharacterAdded) -- connect the function to CharacterAdded event
end)
Needless, I think the issue you were encountering was due to the fact you were multiplying the player’s head position by Vector3.new(0, 0.03, 0), this would place the attachment at 3% of the player’s Head Y position