Structure
There's a much simpler structure:
Go up from 0 to 255
Go down from 255 to 0
(Repeat)
Here's what that would look like:
while true do
for bright = 0, 1, 0.03 do
wait()
end
for bright = 1, 0, -0.03 do
wait()
end
end
Setting BrickColor
The BrickColor.new constructor can take a Color3 value. Color3 values use an R, G, and B ranging from 0 to 1 (not 0 to 255 as is reported by the Properties tab). So this could look like
local brick = script.Parent
...
brick.BrickColor = BrickColor.new( Color3.new( bright, bright, bright ) )
...
Not Using BrickColor? (Getting it continuous)
So, this will more or less work. The problem is that BrickColors are ultimately discrete. There are only a handful of them, it won't actually be a smooth transition.
There isn't a simple solution to this.
At this point, there are two solutions.
SpecialMesh: The trick I came up with a number of years ago. Using a FileMesh, you can modify the VertexColor property (which is a Vector3, not a Color3) when it has a pure white texture to get the mesh to be that color.
I had MeshDB upload this brick mesh that is 0.5x0.5x0.5. Set its Scale to be twice the size of the brick, e.g.,
brick.Mesh.Scale = brick.Size * 2
Then set its VertexColor:
...
brick.Mesh.VertexColor = Vector3.new( bright, bright, bright )
...
(Remember it needs a pure white TextureId -- upload one yourself or just search "White" on decals)
GUIs: The other option is to use 6 different SurfaceGuis. This requires more instances, and will ignore lighting.