In order to do this without it going out of bounds, you will need to use a few checks. You do have the basics down though.
local color = script.Parent.Background.BackgroundColor3
local r = script.Parent.Background.BackgroundColor3.r
local g = script.Parent.Background.BackgroundColor3.g
local b = script.Parent.Background.BackgroundColor3.b
for i = 1, 255 do
wait(0.1)
g = i
b = i
print(r.. g.. b)
color = Color3.fromRGB(r,g,b)
end
Now if the r/g/b values are all different numbers, it gets a bit more complicated, but not by much:
local color = script.Parent.Background.BackgroundColor3
local r = script.Parent.Background.BackgroundColor3.r
local g = script.Parent.Background.BackgroundColor3.g
local b = script.Parent.Background.BackgroundColor3.b
local red = false
local green = false
local blue = false
for i = 1, 255 do
wait(0.1)
if r ~=255 and not red then
r = r + 1
else
red = true
end
if g ~=255 and not green then
g = g + 1
else
green = true
end
if b ~= 255 and not blue then
b = b + 1
else
blue = true
end
print(r.. g.. b)
color = Color3.fromRGB(r,g,b)
if red and green and blue then
break
end
end
5 comments
Wait, I am figuring it out
Because you aren't giving it intervals to go by, try "for i = 1,255,1"
Also a recommendation would be to start using i instead of 1. Better practice other wise you might as well be using a while loop.
@Typically, for loops default to iterate by 1 if no value is given
@Mr_Pure, it has nothing to do with "good practice". maybe he just wants it to increase by one 255 times. if he used "i" in his addition, it would be doing: g+1, g+2, g+3 ... g+255