How to make a part and gui have a smooth rainbow animation

This is code for a color changing GUI that I made a while ago (it moves too):
local object = script.Parent

object.AnchorPoint = Vector2.new(0.5, 
0.5)

wait(2)

object:TweenPosition(UDim2.new(0, 0, 0 
,0),nil,nil,5)

object:TweenSize(UDim2.new(0, 400, 0, 
100))

local t = 10;

while wait() do

local hue = tick() % t / t

local color = Color3.fromHSV(hue,1,1)

script.Parent.BackgroundColor3 = color

end