Rainbow header disappearing after reset

Hi, so I have a header/title/whatever you want to call it using a Overhead GUI and so I have it set through a group role based color that is granted and for some reason, it does give you the rainbow effect, but goes away after you reset.

Here’s some code:
Snippet from one module:

function ProductInfo.Developers(player)
	DataModule.RestrictedAreaAccess[player.UserId] = true
	ProductInfo.ColoredTitles(player)
	HeaderCreator.RainbowHeader(player)
end

Main code for the RAINBOW title:

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
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
	local rank = player:GetRankInGroup(Configurations.GROUP_ID)
	
	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

That’s what creates the general headers.

I really don’t know what the issue is, if you need more info let me know.

Check the ResetOnSpawn value on the Gui, and if it’s checked, uncheck it. That’s all I can help with.

Yeah, I did that and it’s still having that issue
:>

This wasn’t always a problem until now, and I don’t understand it.

Create a CharacterAdded event and readd the title to the user everytime they die

It’s weird because the title itself stays, just the rainbow effect doesn’t so i’m not sure what to /actually/ write

Oh, I see.
I mean it would be easiest to just recreate the title on death, but if you’re specifically wanting the rainbow to start again you could do something like this

CharacterAdded:Connect(function(char)
	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)

Oh, I poked around other modules I had and forgot there was something like this written

Players.PlayerAdded:Connect(function(player)
	formNewLeaderboard(player)
	player.CharacterAdded:Connect(function(character)
		if (not character:WaitForChild("Head"):FindFirstChild("OverheadGui")) then
			HeaderCreator.CreateTitle(player)
		end
	end)
end)

Ah so you can literally just call the

HeaderCreator.RainbowHeader

Right after it and it should work as you’d like!

Players.PlayerAdded:Connect(function(player)
	formNewLeaderboard(player)
	player.CharacterAdded:Connect(function(character)
		if (not character:WaitForChild("Head"):FindFirstChild("OverheadGui")) then
			HeaderCreator.CreateTitle(player)
        end

        HeaderCreator.RainbowHeader(player, "")
	end)
end)

My only concern is making sure that it goes through that check in the other module dictating whether or not they are eligible to receiving that role.

local function groupMemberBenefits(player)
	local rank = player:GetRankInGroup(Configurations.GROUP_ID)
	if (rank >= 6) then ProductInfo.HighGroupRole(player) end
	if (rank >= 252) then ProductInfo.Developers(player) end
end

Which is in its own module

local function groupMemberBenefits(player)
    local rank = player:GetRankInGroup(Configurations.GROUP_ID)
    if (rank >= 6) then ProductInfo.HighGroupRole(player) return "HR" end
    if (rank >= 252) then ProductInfo.Developers(player) return "Dev" end
end

Players.PlayerAdded:Connect(function(player)
    formNewLeaderboard(player)
    player.CharacterAdded:Connect(function(character)
        if (not character:WaitForChild("Head"):FindFirstChild("OverheadGui")) then
            HeaderCreator.CreateTitle(player)
        end
        
        if (groupMemberBenefits(player) == "Dev") then
            HeaderCreator.RainbowHeader(player, "")
        end
    end)
end)

I tried all of that and it’s still going away after resetting D:

Maybe the problem is somewhere else?

Add a print after the == dev to see if its even making it past it

Oh, I just did and it’s not reaching that line at all

I think I might’ve figured it out actually with this:

Players.PlayerAdded:Connect(function(player)
	formNewLeaderboard(player)
	player.CharacterAdded:Connect(function(character)
		if (not character:WaitForChild("Head"):FindFirstChild("OverheadGui")) then
			HeaderCreator.CreateTitle(player)
		end

		if (ProductInfo.Developers(player) == true) then
			HeaderCreator.RainbowHeader(player)
		end
	end)
end)

Now, I gotta see if it actually does what it’s intended and not just giving everyone it.

Oh, I see whats wrong

local function groupMemberBenefits(player)
    local rank = player:GetRankInGroup(Configurations.GROUP_ID)
    if (rank >= 252) then ProductInfo.Developers(player) return "Dev" end
    if (rank >= 6) then ProductInfo.HighGroupRole(player) return "HR" end
end
1 Like

I found out CharacterAdded is also an event other than PlayerAdded… Adding that onto the PlayerAdded:Connect function actually fixed everything.