GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
|
| 12 Jan 2013 03:26 AM |
How could I make a script that changes the color of an GUI object slowly to a certain color. (Like when I trigger a function, it kinda 'moves' to the certain color.)
Thanks :3 |
|
|
| Report Abuse |
|
|
1WOOF1
|
  |
| Joined: 03 May 2009 |
| Total Posts: 20682 |
|
| |
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 12 Jan 2013 04:54 AM |
You could use Vector3 to lerp and then change it to color. Haxy, but naic :D
for num=1,100 do--I'm not using decimal numbers, since Lua likes to change them for some reason. v = Vector3.new(beginingColor):lerp(Vector3.new(endColor),num/100) GUI.BackgroundColor3 = Color3.new(v.x,v.y,v.z) wait() end
Should work nicely. Might test it out too. |
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 12 Jan 2013 05:09 AM |
| Woof gave bad example, since in roblox you don't use values for colors between 1-255, but 0-1. |
|
|
| Report Abuse |
|
|
GiverLol
|
  |
| Joined: 20 Dec 2010 |
| Total Posts: 810 |
|
|
| 12 Jan 2013 06:18 AM |
function slide(Red, Green, Blue)
local red = math.floor(script.Parent.BackgroundColor3.r * 255) local green = math.floor(script.Parent.BackgroundColor3.g * 255) local blue = math.floor(script.Parent.BackgroundColor3.b * 255)
print("__________________")
if red < Red then print("Make red bigger") end
if red > Red then print("Make red smaller") end
if red == Red then print("Keep red the same") end
if green < Green then print("Make green bigger") end
if green > Green then print("Make green smaller") end
if green == Green then print("Keep green the same") end
if blue < Blue then print("Make blue bigger") end
if blue > Blue then print("Make blue smaller") end
if blue == Blue then print("Keep blue the same") end
print("------------------") end
slide(137, 100, 50) |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 12 Jan 2013 08:18 AM |
"script.Parent.BackgroundColor3.r * 255"
Color3 requires numbers between 0-1. If you'll set color higher than 1, it will count as 1(max). |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 12 Jan 2013 08:20 AM |
Also this one worked perfectly. So if you'd want to have it go from red to blue, you'd just do this:
for num=1,100 do--I'm not using decimal numbers, since Lua likes to change them for some reason. v = Vector3.new(1,0,0):lerp(Vector3.new(0,0,1),num/100) GUI.BackgroundColor3 = Color3.new(v.x,v.y,v.z) wait() end
|
|
|
| Report Abuse |
|
|