How would I do this?' w '
1 | textbutton = script.Parent --Assuming this is where it is. |
2 | waittime = . 1 --How long it takes for the TextButton to change color ONCE (In Seconds) |
3 |
4 | while true do --Starts the loop. |
5 | textbutton.BackgroundColor 3 = Color 3. new( 0 , 0 , 0 ) --Changes color to black. |
6 | wait(waittime) --Time to wait to change color. |
7 | textbutton.BackgroundColor 3 = Color 3. new( 255 , 0 , 0 ) --Changes color to red. |
8 | wait(waittime) --Time to wait to change color again. |
9 | 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-
01 | local Btn = script.Parent |
02 | local Time = . 1 |
03 | local C 1 = Color 3. new() -- Black |
04 | local C 2 = Color 3. new( 1 , 0 , 0 ) -- Red |
05 |
06 | while true do |
07 | Btn.BackgroundColor 3 = C 1 |
08 | wait(Time) |
09 | Btn.BackgroundColor 3 = C 2 |
10 | wait(Time) |
11 | 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:
1 | local function newColor(r,g,b) |
2 | return Color 3. new(r/ 255 ,g/ 255 ,b/ 255 ) |
3 | end |
4 |
5 | frame.BackgroundColor 3 = newColor( 255 , 0 , 0 ) --Red |
It is also good to note that a quick shortcut for a black colour is to simply do this:
1 | frame.BackgroundColor 3 = Color 3. new() --Black |
This works because by default it creates a Color3 object with (0,0,0) values.