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

How could I make the color change look more smoother?

For example Kahoot it's background color changes really smoothly, how could I edit this script to do something like that?

while true do
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(85, 0, 127)
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(0, 85, 255)
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(0, 170, 0)
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(255, 255, 0)
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(255, 85, 0)
	wait(.25)
	script.Parent.BackgroundColor3 = Color3.new(255, 0, 0)
end

3 comments

0

How about using tweenService?

0

TweenService can only be used on BaseParts and judging my the BackGroundColor3 property, this is on a GUI class.

1 answer

✓ Accepted answer

You could use the Color3 lerp method. It takes two arguments: a Color3 value (goal) and a number value (alpha).

Incorporate this into a for loop, and you have a smooth transition between two different colours.

function lerpToColor3(obj, c3)
	for i = 0, 1, 0.05 do
		obj.BackgroundColor3 = obj.BackgroundColor3:lerp(c3, i)
		wait()
	end
end

Where obj is the Gui instance being modified, and c3 is the goal you're trying to reach, e.g.

lerpToColor3(script.Parent, BrickColor.new("Bright red").Color)

I'm not entirely sure whether this is a great implementation or not, but I hope it works! Here's the wiki article for reference.

1 comment

0

Thanks, I will for sure try this out and maybe make a list of different BrickColor names!

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