TextLabel Text not becoming rainbow

I have a main menu when u join the game, and I’m trying to make the play button rainbow. I used a solution from the devforum, but it didnt work

local RS = game:GetService("RunService")

local rainbow = script.Parent  -- Text Label
local grad = rainbow.UIGradient

local counter = 0      
local w = math.pi / 12  
local CS = {}           
local num = 15 			
local frames = 0		

RS.Heartbeat:Connect(function()
	if math.fmod(frames, 2) == 0 then
		for i = 0, num do
			local c = Color3.fromRGB(127 * math.sin(w*i + counter) + 128, 127 * math.sin(w*i + 2 * math.pi/3 + counter) + 128, 127*math.sin(w*i + 4*math.pi/3 + counter) + 128)
			table.insert(CS, i+1, ColorSequenceKeypoint.new(i/num, c))
		end
		grad.Color = ColorSequence.new(CS)
		CS = {}
		counter = counter + math.pi/40
		if (counter >= math.pi * 2) then
			counter = 0
		end
	end
	if frames >= 1000 then
		frames = 0
	end
	frames = frames + 1
end)

1 Like

How so? Are there any errors in the output?

1 Like

No, there isn’t, weirdly. The text just stays normal.


Also, the TextLabel background is transparent, theres a seperate textbox without text, and I put a textlabel to make that rainbow.

Are you trying to make this?

Yes, but I used the tralalah one.

I may not be correct, but it seems like you’re not setting the color.
Use rainbow.Color = c (might need some tweaking, color might be Color3)
Also, might be wrong, you’re not defining a new function either.

Not sure what you mean,
could you put it into the script and explain a little further?

local RS = game:GetService("RunService")

local rainbow = script.Parent  -- Text Label
local grad = rainbow.UIGradient

local counter = 0      
local w = math.pi / 12  
local CS = {}           
local num = 15 			
local frames = 0		

RS.Heartbeat:Connect(function()
	if math.fmod(frames, 2) == 0 then
		for i = 0, num do
			local c = Color3.fromRGB(127 * math.sin(w*i + counter) + 128, 127 * math.sin(w*i + 2 * math.pi/3 + counter) + 128, 127*math.sin(w*i + 4*math.pi/3 + counter) + 128)
			table.insert(CS, i+1, ColorSequenceKeypoint.new(i/num, c))
		end
		grad.Color = ColorSequence.new(CS)
		CS = {}
		counter = counter + math.pi/40
		if (counter >= math.pi * 2) then
			counter = 0
		end
	end
	if frames >= 1000 then
		frames = 0
	end
	frames = frames + 1
        rainbow.Color = color2 --change color2 to the variable that is the color
end)
1 Like

Oop–
A quick search through the API and I found out that to change the text, it needs to be:

rainbow.TextColor3 = color2 

Sorry for the mixup :sweat_smile:

Sorry for the late reply, but Color2 doesn’t exist

local RS = game:GetService("RunService")
local rainbow = script.Parent  -- Text Label
local grad = rainbow.UIGradient
rainbow.TextColor3 = Color2
local counter = 0      
local w = math.pi / 12  
local CS = {}           
local num = 15 			
local frames = 0		

RS.Heartbeat:Connect(function()
	if math.fmod(frames, 2) == 0 then
		for i = 0, num do
			local c = Color3.fromRGB(127 * math.sin(w*i + counter) + 128, 127 * math.sin(w*i + 2 * math.pi/3 + counter) + 128, 127*math.sin(w*i + 4*math.pi/3 + counter) + 128)
			table.insert(CS, i+1, ColorSequenceKeypoint.new(i/num, c))
		end
		grad.Color = ColorSequence.new(CS)
		CS = {}
		counter = counter + math.pi/40
		if (counter >= math.pi * 2) then
			counter = 0
		end
	end
	if frames >= 1000 then
		frames = 0
	end
	frames = frames + 1
end)

As I said before,

Change color2 to the needed var.

I changed Color2 to Color3, so rainbow.TextColor3 = Color3 and it says

You may need to use color3.New() for the table, and make a UI gradient/a loop that changes the colors according to the list.

ah, I do have a UIGradient in the TextLabel

1 Like

No errors, but the color isnt changing.

local RS = game:GetService("RunService")
local rainbow = script.Parent  -- Text Label
local grad = rainbow.UIGradient
rainbow.TextColor3 = Color3:new()
local counter = 0      
local w = math.pi / 12  
local CS = {}           
local num = 15 			
local frames = 0		

RS.Heartbeat:Connect(function()
	if math.fmod(frames, 2) == 0 then
		for i = 0, num do
			local c = Color3.fromRGB(127 * math.sin(w*i + counter) + 128, 127 * math.sin(w*i + 2 * math.pi/3 + counter) + 128, 127*math.sin(w*i + 4*math.pi/3 + counter) + 128)
			table.insert(CS, i+1, ColorSequenceKeypoint.new(i/num, c))
		end
		grad.Color = ColorSequence.new(CS)
		CS = {}
		counter = counter + math.pi/40
		if (counter >= math.pi * 2) then
			counter = 0
		end
	end
	if frames >= 1000 then
		frames = 0
	end
	frames = frames + 1
end)

image

Are you sure the UI Gradient’s Property Enabled set to true?

Yeah the UIGradient is enabled.

Is it possible to send a video, with pictures I can’t infer a solution

robloxapp-20201008-1245406 Here

Any solution as of yet?

(30 ch