My BillboardGui is Not Showing Up

  1. What do you want to achieve?
    I own a restaurant group that is currently in construction. I created one of those over-head GUIs like in other roleplay games stating the player’s username and role in the group.

  2. What is the issue?
    I am currently receiving no errors, but when a player resets the GUI is gone.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I searched far and wide, but I came across nothing compatible with my system.

This is the script at it’s current state (Note: it’s parent is Workspace):

local plrs = game:GetService("Players")
local group = 5513883
local function GiveTag(plr)
	repeat wait(0.1) until plr.Character
	local char = plr.Character
	char:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
	local tag = game:GetService("ReplicatedStorage"):WaitForChild("Tag"):Clone()
	tag:WaitForChild("User").Text = plr.Name
	tag:WaitForChild("Rank").Text = plr:GetRoleInGroup(group)
	tag.Parent = char:WaitForChild("Head")
	char.Humanoid.Died:Connect(function()
		char:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		local tag = game:GetService("ReplicatedStorage"):WaitForChild("Tag"):Clone()
		tag:WaitForChild("User").Text = plr.Name
		tag:WaitForChild("Rank").Text = plr:GetRoleInGroup(group)
		tag.Parent = char:WaitForChild("Head")
	end)
end
wait()
plrs.PlayerAdded:Connect(function(plr)
	pcall(function()
		coroutine.wrap(GiveTag(plr))
	end)
end)

I would appreciate if someone would explain to me what I did wrong, and help me fix my script.

Thanks in advance!

You’re doing it in a PlayerAdded which will only work when player joins. When a character dies the character resets so that means Billboardgui will be gone. If you use a CharacterAdded event inside the PlayerAdded event and do it inside the CharacterAdded it will work when character dies.

2 Likes

@AtomTostcuOzgurUsta is correct.

Here’s what I changed in order to fix your Script, which works according to my test! @PrismaticFruits
Make sure to scroll within the code block to see everything!

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Group = 5513883

local function CreateTag(Character, Player)

    Player = Players:GetPlayerFromCharacter(Character)

    local Humanoid = Character:WaitForChild("Humanoid")
    local Head = Character:WaitForChild("Head")

    local Tag = ReplicatedStorage:WaitForChild("Tag")
    local TagClone = Tag:Clone()

    local TagCloneUser = TagClone:WaitForChild("User")
    local TagCloneRank = TagClone:WaitForChild("Rank")

    Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None

    TagCloneUser.Text = Player.Name
    TagCloneRank.Text = Player:GetRoleInGroup(Group)
    TagClone.Parent = Head

end

local function GiveTag(Player) 

    Player.CharacterAdded:Connect(CreateTag)

end

Players.PlayerAdded:Connect(GiveTag)

for _, Player in ipairs(Players:GetPlayers()) do

    coroutine.wrap(GiveTag)(Player)

end

Tip: I recommend staying consistent with the way you name your variables. You could use one of the following: camelCase, PascalCase, snake_case, or UPPERCASE.