How to make rainbow text GUI

I want to make overhead GUI for my game and I added a few tags, Guest, Fan, Partner, Developer, and Owner tags, like so:

But, I want the Owner text to be a rainbow color that flows, any tips?

Here’s my script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local overheadGui = ReplicatedStorage:WaitForChild("OverheadGui")
local playerName = overheadGui:WaitForChild("PlayerName")

local groupId = 13621453

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()
		
		local playerRank = player:GetRankInGroup(groupId)
		
		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"
	
		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = player.Name
		
		if playerRank == 255 then
			overheadGuiClone.PlayerRank.Text = "Owner"
			overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(255, 255, 255) -- I want this to be a rainbow color instead of a static color
		elseif playerRank == 4 then
			overheadGuiClone.PlayerRank.Text = "Admin"
			overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
		elseif playerRank == 3 then
			overheadGuiClone.PlayerRank.Text = "Developer"
			overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(255, 136, 0)
		elseif playerRank == 2 then
			overheadGuiClone.PlayerRank.Text = "Partner"
			overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
		elseif playerRank == 1 then
			overheadGuiClone.PlayerRank.Text = "Fan"
			overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
		elseif playerRank == 0 then
			overheadGuiClone.PlayerRank.Text = "Guest"
		end
	end)
end)
2 Likes

tween service to change color like rainbow

2 Likes

How can I use TweenService to change the color?

2 Likes

There are multiple ways to do this.

Here is one of them -
Using tick() with HSV

[Take this as an example that could be used in yours]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local overheadGui = script.NameTag
local groupId = 00000000 --your group ID

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local head = character.Head
		local overheadGuiClone = overheadGui:Clone()

		local Success,Result = pcall(function()
			return player:GetRankInGroup(groupId)
		end)

		local humanoid = character.Humanoid
		humanoid.DisplayDistanceType = "None"

		overheadGuiClone.Parent = head
		overheadGuiClone.Adornee = head
		overheadGuiClone.PlayerName.Text = player.Name

		if Success then
			if Result >= 254 then
				overheadGuiClone.PlayerRank.Text = "Owner"
				spawn(function()
					while task.wait() do
						local t = 5; 
						local hue = tick() % t / t
						local colorrr = Color3.fromHSV(hue, 1, 1)
						overheadGuiClone.PlayerRank.TextColor3 = colorrr
					end
				end)
			elseif Result == 4 then
				overheadGuiClone.PlayerRank.Text = "Admin"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(163, 0, 0)
			elseif Result == 3 then
				overheadGuiClone.PlayerRank.Text = "Developer"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(255, 136, 0)
			elseif Result == 2 then
				overheadGuiClone.PlayerRank.Text = "Partner"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(30, 226, 0)
			elseif Result == 1 then
				overheadGuiClone.PlayerRank.Text = "Fan"
				overheadGuiClone.PlayerRank.TextColor3 = Color3.fromRGB(0, 174, 255)
			elseif Result == 0 then
				overheadGuiClone.PlayerRank.Text = "Guest"
			end
		end
	end)
end)
6 Likes

Not sure if this is any help but I found this tutorial on something like that.

I don’t think its exactly what you want but it has the basic idea that you can implement into your own code for what you want.

3 Likes

Ma’am you’re the best. I was looking for a solution thanks

4 Likes