So my problem is that the brightness of the light (Light.Brightness at line 42) goes lower the more items i add to the ‘display’ surfacegui, even though they are 0 on the transparency
local Light = script.Parent
local Display = script.Parent.Parent.Display
local aR, aG, aB, aT = {}, {}, {}, {}
local function average(t)
local sum_num = 0
for _, num in pairs(t) do
sum_num += num
end
local avg = sum_num / #t
return avg
end
while true do
for _, obj in pairs(Display:GetDescendants()) do
if obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
table.insert(aR, obj.ImageColor3.R or 0)
table.insert(aB, obj.ImageColor3.G or 0)
table.insert(aG, obj.ImageColor3.B or 0)
table.insert(aT, obj.ImageTransparency or 0)
elseif obj:IsA("TextLabel") or obj:IsA("TextButton") or obj:IsA("TextBox") then
table.insert(aR, obj.TextColor3.R or 0)
table.insert(aB, obj.TextColor3.G or 0)
table.insert(aG, obj.TextColor3.B or 0)
table.insert(aT, obj.TextTransparency or 0)
end
table.insert(aR, obj.BackgroundColor3.R or 0)
table.insert(aG, obj.BackgroundColor3.G or 0)
table.insert(aB, obj.BackgroundColor3.B or 0)
table.insert(aT, obj.BackgroundTransparency or 0)
end
local avgColor3 = Color3.new(average(aR), average(aB), average(aG))
Light.Color = avgColor3
Light.Brightness = math.floor(math.abs(average(aT)))
task.wait(1)
table.clear(aR) table.clear(aG) table.clear(aB) table.clear(aT)
end