So, I have a header system with Billboard GUI’s already set up and i’m currently trying to set up a rainbow header function so that your tag goes through the RGB sequence, it’s easier to show in code:
function HeaderCreator.RainbowHeader(player, header)
local header = player.Character.Head:FindFirstChild("OverheadGui")
local labels, x = {}, 0
for _, inst in pairs(header:GetDescendants()) do
if (inst:IsA("TextLabel") and inst.Name ~= "Label2" and inst.Name ~= "Label4") then table.insert(labels, inst) end
end
coroutine.wrap(function()
while (header.Parent.Parent ~= nil) do
wait(.08)
for _, label in pairs(labels) do
label.TextColor3 = Color3.fromHSV(x,1,1)
x = x >= 1 and 0 or x + 1/255
end
end
end)()
end
First issue is the line where local header gets initialized, it returns an error with indexing nil for WaitForChild, and then another error it spits out sometimes would be header:GetDescendants()
It works sometimes, then doesn’t work at all. It’s not consistent.
function HeaderCreator.RainbowHeader(player, header)
local char = player.Character or player.CharacterAdded:Wait()
local header = char:WaitForChild("Head"):WaitForChild("OverheadGui")
local labels, x = {}, 0
for _, inst in pairs(header:GetDescendants()) do
if (inst:IsA("TextLabel") and inst.Name ~= "Label2" and inst.Name ~= "Label4") then table.insert(labels, inst) end
end
coroutine.wrap(function()
while (header.Parent.Parent ~= nil) do
wait(.08)
for _, label in pairs(labels) do
label.TextColor3 = Color3.fromHSV(x,1,1)
x = x >= 1 and 0 or x + 1/255
end
end
end)()
end
I would like to add on (Mainly because I forgot lol) that what I did there was this:
I changed the Character to it’s own variable that first checks to see if the Character exists, then if it doesn’t, it waits until the character is added with the event .CharacterAdded. The event automatically passes through the Character value, so you can use it to easily wait until the player is loaded. This is nifty because it allows you to wait until a player is respawned too.
Oh that’s really neat actually, but another issue that comes up with is that once you reset, the rainbow tag goes away. Is there a workaround this case?
You can use the Humanoid.Died event to check for it.
local humanoid = character.Humanoid -- Not doing anything fancy with waits or something since I have already demonstrated how that works
humanoid.Died:Connect(function()
-- Do whatever
end)
If you meant that you want the tag to appear again, then:
player.CharacterAdded:Connect(function(char)
local head = char:WaitForChild("Head")
GUIHERE.Parent = head -- Replace "GUIHERE" with your billboard GUI
end)
EDIT: Adding on, once again;
I would highly recommend saving the GUI to a variable, so that each time the player respawns you can set another variable to yourGUIthing:Clone() (Which basically creates a copy of the object that you can manipulate with the variable) and set it’s parent to the characters head like so:
local gui = game.ReplicatedStorage.mycoolgui -- change the location to wherever your Gui is
player.CharacterAdded:Connect(function(char)
local cloneui = gui:Clone()
cloneui.Parent = char:FindFirstChild("Head")
end)
function HeaderCreator.CreateTitle(player, developer)
local header = ReplicatedStorage.OverheadGui:Clone()
local groupRole = player:GetRoleInGroup(Configurations.GROUP_ID)
local level = player.player_stats.Level
local locked = false
header.Label.Text = "Level ".. level.Value
header.Label2.Text = "- ".. groupRole .. " -"
header.Label3.Text = player.DisplayName
header.Label3.Size = UDim2.new(2,0,0.4,0)
if player.DisplayName == player.Name then
header.Label4.Text = " "
elseif player.DisplayName ~= player.Name then
header.Label4.Text = "@"..player.Name
header.Label4.Size = UDim2.new(2,0,0.25,0)
header.Label4.TextColor3 = Color3.fromHSV(0, 0, 0.588235)
end
header.Size = UDim2.new(5,0,1.5,0)
if (player.Character:WaitForChild("Head"):FindFirstChild("OverheadGui")) then
player.Character.Head.OverheadGui:Destroy()
end
-- AFK HANDLER --
AFKEvent.OnServerEvent:Connect(function(player,afk)
local header2 = player.Character:WaitForChild("Head"):FindFirstChild("OverheadGui")
if afk then
header2.Label3.Text = "[AFK] "..player.DisplayName
if player.DisplayName == player.Name then -- HIDES LABEL4 IF DOESNT HAVE A DISPLAY NAME
header2.Label4.Text = " "
elseif player.DisplayName ~= player.Name then -- SHOWS LABEL4 IF HAS A DISPLAY NAME
header2.Label4.Text = "@"..player.Name
-- header.Label4.Size = UDim2.new(5,0,1.5,0)
end
else
header2.Label3.Text = player.DisplayName
if player.DisplayName == player.Name then
header2.Label4.Text = " "
elseif player.DisplayName ~= player.Name then
header2.Label4.Text = "@"..player.Name
-- header.Label4.Size = UDim2.new(5,0,1.5,0)
end
end
end)
-- END OF AFK HANDLE --
header.Parent = player.Character:WaitForChild("Head")
if (connections[player.UserId]) then connections[player.UserId]:Disconnect() end
connections[player.UserId] = level.Changed:Connect(function(value)
header.Label.Text = "Level ".. value
header.Label2.Text = "- ".. groupRole .." -"
end)
end
I’ll try it out! Also, would you like me to just like… show you everything I have to work with to give you a better idea? It’s hard to show absolutely never when it comes to this kind of particular issue I think. I have diz n whatnot