Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script is supposed to change the color of a frame at a speed. Why doesn't it work?

The script worked before but then it stopped working after I added more colors & variables. I wanted the script to flash rainbow colors but it stopped working like I said after adding the variables and colors

-- Colors
local function c3i(s,e,a)
    -- Start, end, alpha
    return Color3.new(s.r+(e.r-s.r)*a,s.g+(e.g-s.g)*a,s.b+(e.b-s.b)*a);
end;



local LightGreen = Color3.new(0.545098039, 0.764705882, 0.290196078) -- 
local Yellow = Color3.new(1, 0.921568627, 0.231372549) -- 
local Amber = Color3.new(1, 0.756862745, 0.0274509804) -- 
local DeepOrange = Color3.new(1, 0.341176471, 0.133333333) -- 
local Pink = Color3.new(0.91372549, 0.117647059, 0.388235294) -- 
local Green = Color3.new(0.145098039, 0.607843137, 0.141176471) -- 
local Lime = Color3.new(0.803921569, 0.862745098, 0.223529412) -- 
local Orange = Color3.new(0.803921569, 0.862745098, 0.223529412) -- 
local Red = Color3.new(0.898039216, 0.109803922, 0.137254902) -- 
--These are not done yet :(!!  Also ignore the black and white tags
local Purple = Color3.new(1, 0.921568627, 0.231372549) -- 
local Indigo = Color3.new(1, 0.921568627, 0.231372549) -- 
local LightBlue = Color3.new(1, 0.921568627, 0.231372549) -- 
local Cyan = Color3.new(1, 0.921568627, 0.231372549) -- 
local Grey = Color3.new(1, 0.921568627, 0.231372549) -- 
local BlueGrey = Color3.new(1, 0.921568627, 0.231372549) -- 
local DeepPurple = Color3.new(1, 0.921568627, 0.231372549) -- 
local Blue = Color3.new(1, 0.921568627, 0.231372549) -- 
local Teal = Color3.new(1, 0.921568627, 0.231372549) -- 
local Brown = Color3.new(1, 0.921568627, 0.231372549) -- 
local Black = Color3.new(1, 0.921568627, 0.231372549) -- 

local TRANSITION_TIME = 120 -- 5 seconds

local i = 0;
local TimeScale = TRANSITION_TIME ^-1;
while i < 1 do
    script.Parent.BackgroundColor3 = c3i( LightGreen, Yellow, Amber, DeepOrange,Pink,Green,Lime,Orange,Red,Purple,Indigo,LightBlue,Cyan,Grey,BlueGrey,DeepPurple,Blue,Teal,Brown,Black, i);
    i = i + wait()*TimeScale;
end;

The original script worked fine. This is the original script.

local function c3i(s,e,a)
    -- Start, end, alpha
    return Color3.new(s.r+(e.r-s.r)*a,s.g+(e.g-s.g)*a,s.b+(e.b-s.b)*a);
end;



local FROM_COLOR = Color3.new(0, 0, 0) -- black
local TO_COLOR = Color3.new(1, 1, 1) -- white
local TRANSITION_TIME = 5 -- 5 seconds

local i = 0;
local TimeScale = TRANSITION_TIME ^-1;
while i < 1 do
    script.Parent.BackgroundColor3 = c3i( FROM, TO, i);
    i = i + wait()*TimeScale;
end;

1 answer

Your problem is you're passing several arguments to the function c31 when it only has three parameters. 21, to be exact.

If you want the function to fade to a new color after the last one, then you either have to call it over and over with new arguments in different while loops, or you can rewrite it entirely to integrate the while loop into the function and allow it to accept a table of colors as an argument for the end parameter.

I'll see if I can come up with anything more user-friendly, and explain the script to you better.

This discussion is preserved as it was. New answers, comments, and votes are closed.