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)
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.
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)
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)
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)