How would I change the colour of a GUI

How would I make a frame so it starts off black and slowly fades to white then repeats?
could I make a script like this?

local r = 0
local g = 0
local b = 0

while true do
r = r +1
b = b +1
g = g+1
wait(0.1)
end

script.Parent.BackroundColor3 = FromRGB(r,g,b)
1 Like

You would have to use tween service.

Like tween the color?
I do not do tweening and I do not understand.

Here is a example code I whipped up in a minute:

	local tweenservice = game:GetService("TweenService")

while true do
	wait(0.5)
	local tweeninfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
	local tween = tweenservice:Create(script.Parent, tweeninfo, {BackgroundColor3 = Color3.fromRGB(255, 255, 255)})
	tween:Play()
	tween.Completed:Wait()
	local tween2 = tweenservice:Create(script.Parent, tweeninfo, {BackgroundColor3 = Color3.fromRGB(0,0,0)})
	tween2:Play()
	tween2.Completed:Wait()
end
2 Likes

Wouldnt this just make it black then white instantly?

Look at this API. It explains tweening much better than I can:

1 Like

Script worked, thanks a lot @MegaFireball0!

No problem! Glad I could help!