How do I make a part smoothly flash between 2 brick colours using TweenService?

I want to make a part flash between 2 colors while a Boolean value is true, but I don’t know how to use TweenService and can’t find anything helpful on the web (using my search queries).

I’ve tried looking here too, but I couldn’t find anything (as i said before).

Any help is very appreciated. Thanks.

local a = game:GetService("TweenService"):Create(Part, TweenInfo.new(1), {Color = color}):Play()

This is how you tween a parts color. Loop it back and fourth. with different colors

local part = workspace:WaitForChild('Part') --Path to part
local colors = {Color3.new(),Color3.new(1,1,1)} --Array of colors
local speed = 1 --Time in seconds to tween between colors

-- Tween function so you don't have to remember the whole thing every time:
local T = game:GetService('TweenService')
function tween(o,t,l,s,d)
	s = s or Enum.EasingStyle.Linear
	d = d or Enum.EasingDirection.InOut
	local i = TweenInfo.new(l,s,d)
	return T:Create(o,i,t)
end

--Garbage cleanup (May not be needed depending on where and how you use the tween):
local active = true
local destroyed
destroyed = part.Destroying:Connect(function()
	destroyed:Disconnect()
	destroyed = nil
	active = nil
end)

--Loop that will tween between all colors within the array while the "part" exists:
while active do --Loop while "part" exists
	for _,color in colors do --Iterate through all colors in array
		local t = tween(part,{Color=color},speed) --Creating tween
		t:Play() --Playing tween
		t.Completed:Wait() --Yielding until tween has completed
		t = nil --Garbage cleanup to allow for the Tween instance to be garbage collected
	end
end


Not that it’s super important, but there’s no point in using local a in that as you’re just going to set it to nil.