I wanted to make light that turns off when clock time is > 18 and turns on when clock time is > 6 but for some reason it doesnt work and i dont know why
local plight = script.Parent --point light local light = game.Lighting -- lighting light.Changed:Connect(function() if light.ClockTime >= 18 then plight.Enabled = false print(light.ClockTime) end if light.ClockTime >= 6 then print(light.ClockTime) plight.Enabled = true end end)
It's because your script is checking if light.ClockTime >= 6
after checking if light.ClockTime >= 18
, meaning even though plight
is disabled for a millisecond, it is enabled the next milisecond, since if it is greater than 18 then it is also greater than 6. The fix is simple - rather than putting end
and starting a new if-statement, just use elseif
as replacement.