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

Smooth Color Changing?

Heya Guys! I have noticed in games in such when a Surface Gui/Brick Changes color it does it smoothly, what aspect in scripting is that?

2 answers

You can do all sorts of things. I'll give you some code I used recently to make a TextButton's BackgroundColor change from black to white:

local data = script.Parent
local reset = false
local r = 0
local g = 0
local b = 0

while true do
	wait(.005)
	if reset == false then
		r,g,b = r + 5,g + 5,b + 5
		data.BackgroundColor3 = Color3.new(r/255,g/255,b/255)
	end
	if r == 255 then
		reset = true
	end
	if reset == true then
		r,g,b = r - 5,g - 5,b - 5
		data.BackgroundColor3 = Color3.new(r/255,g/255,b/255)
	end
	if r == 0 then
		reset = false
	end
end 

This goes in a script inside the gui object.

Comment if you need help :P

Well you can try all different types of function for that like, -while true do -for i -etc.. Try looking on the ROBLOX Wiki up vote and accept if this helped.

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