How can I make a script that changes the brightness when TimeOfDay changes?

don’t really wanna share my script in case its bad but I just need help with this

local lighting = script.Parent
local function updateTimeOfDay()
    local timeOfDay = lighting:GetAttribute("TimeOfDay")
    if timeOfDay == 20 then
        lighting.Brightness = 0
    elseif timeOfDay == 5 then
        lighting.Brightness = 3
    end
end
lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(updateTimeOfDay)

yes this script should be looping

TimeOfDay returns a string not a number, use ClockTime instead cause it returns a number unlike timeofday

local lighting = script.Parent
local function updateTimeOfDay()
    local timeOfDay = lighting.ClockTime
    if timeOfDay >= 20 then
        lighting.Brightness = 0
    elseif timeOfDay < 20 then
        lighting.Brightness = 3
    end
end
lighting:GetPropertyChangedSignal("ClockTime"):Connect(updateTimeOfDay)

try this it should work

nothing happened, it should be a script tho right?

make a localscript inside startercharacterscripts and put the code in there, also make sure to redefine lighting, it should work I dont see why it wouldn’t, if it still doesnt let me know ill get on studio to make it really quick

yep, that worked! appreciate your help