How would I do this?' w '
textbutton = script.Parent --Assuming this is where it is. waittime = .1 --How long it takes for the TextButton to change color ONCE (In Seconds) while true do --Starts the loop. textbutton.BackgroundColor3 = Color3.new(0, 0, 0) --Changes color to black. wait(waittime) --Time to wait to change color. textbutton.BackgroundColor3 = Color3.new(255, 0, 0) --Changes color to red. wait(waittime) --Time to wait to change color again. end --Ends the loop.
@Discern Color3.new is meant to accept 3 numbers from 0 - 1, so if you want to achieve the 255 effect you should have Color3.new(255/255, 0/255, 0/255) (aka Color3.new(1, 0, 0)). Personally, this is how I'd write the code if I was doing this-
local Btn = script.Parent local Time = .1 local C1 = Color3.new() -- Black local C2 = Color3.new(1, 0, 0) -- Red while true do Btn.BackgroundColor3 = C1 wait(Time) Btn.BackgroundColor3 = C2 wait(Time) end
@Discern @Ekkoh Thank you Ekkoh for clarifying that. I am just making this response because I noticed that your post was down voted and I want to make sure people realize this quirk of roblox GUIs. It is completely counter-intuitive, especially since in the properties panel of studio it displays Color3 properties with numbers ranging from 0-255, but when you edit them with a script, it must be in numbers from 0-1. As a result, I usually create this method whenever I am working with Color3 values to make it a little simpler:
local function newColor(r,g,b) return Color3.new(r/255,g/255,b/255) end frame.BackgroundColor3 = newColor(255,0,0) --Red
It is also good to note that a quick shortcut for a black colour is to simply do this:
frame.BackgroundColor3 = Color3.new() --Black
This works because by default it creates a Color3 object with (0,0,0) values.