How to change text color in every second with local?

local Number = 0

local red = 255

local green = 255

local blue = 255

while task.wait(1) do

script.Parent.Text.Text = "Temperature "..Number.."°C"

Number += 1

script.Parent.Temp.Value = Number

green -= 2

blue -= 2

script.Parent.Text.BackgroundColor3 = Color3.new(red, green, blue)

end
script.Parent.Text.BackgroundColor3 = Color3.fromRGB(red, green, blue)
2 Likes
uiElementWithTextProperty.TextColor3 = Color3.fromRGB(red, green, blue) 
local red = 255
local green = 255
local blue = 255
game:GetService("RunService").RenderStepped:Connect(function()
   script.Parent.Text.Text = "Temperature "..Number.."°C"
   script.Parent.Temp.Value = Number
   task.wait()
   green -= 2; blue -= 2
   script.Parent.Text.BackgroundColor3 = Color3.fromRGB(red, green, blue)
end)

lmk if this works, also if it goes down to 0 or negative (green and blue) and you don’t want that, just set it back to 255

local red = 255
local green = 255
local blue = 255
game:GetService("RunService").RenderStepped:Connect(function()
   if green <= 1 then -- since blue and green are going down at the same time, there's no point in checking blue also, from what I know. 
      green = 255
      blue = 255
   end
   script.Parent.Text.Text = "Temperature "..Number.."°C"
   script.Parent.Temp.Value = Number
   task.wait()
   green -= 2; blue -= 2
   script.Parent.Text.BackgroundColor3 = Color3.fromRGB(red, green, blue)
end)

Color3.new() takes 3 parameters, red green blue, as a number between 0 and 1. The number you are giving it is between 0 and 255. Try changing Color3.new() to Color3.fromRGB()

1 Like